我的系统时钟是2014年9月16日(星期二)
但在密码里,我总是跳到星期一。
DayOfWeek dow = new DateTime().DayOfWeek;
int columnNumber = 0;
columnNumber = columnNumber + 0;
foreach ( DataGridViewRow row in dataGridView1.Rows )
{
switch ( dow )
{
case DayOfWeek.Monday:
columnNumber = 4;
if ( (bool) row.Cells[4].Value == true ) // crashing here with NullReferenceException
{
row.Cells["activeTodayDataGridViewCheckBoxColumn"].Value = true;
}
break;
我有一个DataGridView
Text
DataGridViewCheckBoxColumn
发布于 2014-09-16 17:01:57
new DateTime()
提供的不是今天的日期,而是DateTime
的默认值
您希望将该行更改为:
DayOfWeek dow = DateTime.Now.DayOfWeek;
https://stackoverflow.com/questions/25874523
复制相似问题