选定的日期显示在csharp的datagridview中 [英] selected date to be display in datagridview in csharp
问题描述
我有一个日历(月历控制)
当我选择当月的任何月份时,所有日期都显示在datagridview中。它工作正常。
对于该代码如下;
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。行[row] .Cells [ 0 ]。值= dt1.ToString( DD / MM / YYYY跨度>);
dt1 = dt1.AddDays( 1 );
row ++;
}
}
上面的代码工作正常。
在datagridview我想要第一列复选框和第二列日期(选定月份日期)
然后我在datagrdiveiw中添加复选框列。
错误显示如下;
teh datagridview checkboxcell类型错误。
以下步骤在datgridview中添加复选框。
右键单击datagridview,然后选择Edit Column并添加
Datagridview CheckBox列。
然后在第一列的datagridview中添加复选框,日期是第二列。
< blockquote>您好,
如果您的复选框列是第一列,请参阅单元格1而不是0.
DGVCalendar.Rows [row] .Cells [ 1 ]。Value = dt1.ToString( dd / MM / yyyy);
最好的问候
Muthuraja
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;
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.
Hi,
If the your check box column is first column, Refer the cell 1 instead of 0.
DGVCalendar.Rows[row].Cells[1].Value = dt1.ToString("dd/MM/yyyy");
Best Regards
Muthuraja
这篇关于选定的日期显示在csharp的datagridview中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!