Click here to Skip to main content
15,903,856 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
i have one calendar(Month Calendar Control)

When i select any month that month all date is displaying in datagridview. it is working fine.

For that code as follows;
C#
private void Faculty_Available_Calendar_DateChanged(object sender, DateRangeEventArgs e)
{
    DateTime dt1 = Faculty_Available_Calendar.SelectionStart;
    dt1 = new DateTime(dt1.Year, dt1.Month, 1);
    DateTime dt2 = dt1.AddMonths(1);
    int numDays = (dt2 - dt1).Days;
    if (DGVCalendar.RowCount < numDays)
    {
        DGVCalendar.RowCount = numDays;
    }
    int row = 0;
    while (dt1 < dt2)
    {
        DGVCalendar.Rows[row].Cells[0].Value = dt1.ToString("dd/MM/yyyy");
        dt1 = dt1.AddDays(1);
        row++;
    }
}

the above code is working fine.

In the datagridview i want First column checkbox and second column Date(selected month date)

Then i add check box column in datagrdiveiw.

Error shows as follows;

Teh datagridview checkboxcell has wrong type.

The following steps to add checkbox in the datgridview.

right cick the datagridview,and select the Edit Column and add the
Datagridview CheckBox Column.

Then checkbox is added in the datagridview in the first column and date is the second column.
Posted
Updated 20-Feb-13 17:59pm
v2
Comments
Karthik Harve 20-Feb-13 23:59pm    
[Edit] pre tags added

1 solution

Hi,

If the your check box column is first column, Refer the cell 1 instead of 0.

C#
DGVCalendar.Rows[row].Cells[1].Value = dt1.ToString("dd/MM/yyyy");


Best Regards
Muthuraja
 
Share this answer
 
Comments
[no name] 21-Feb-13 0:11am    
do as mentined by (Muthuraja).he is right.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900