0

My system clock is 9/16/2014 (Tuesday)

But in code, I'm always jumping to Monday.

DayOfWeek dow = DateTime.Now.DayOfWeek;
int columnNumber = 0;

columnNumber = columnNumber + 0;

foreach ( DataGridViewRow row in dataGridView1.Rows )
{
  switch ( dow )
  {
  case DayOfWeek.Monday:
    columnNumber = 4;
    if (Int32.Parse(row.Cells[columnNumber].Value.ToString()) == 1)
    {
         row.Cells["activeTodayDataGridViewCheckBoxColumn"].Value = true;
    }
    break;

I have a DataGridView

  • Columns 0—3 are Text
  • Columns 4—9 are DataGridViewCheckBoxColumn
software is fun
  • 7,286
  • 18
  • 71
  • 129

1 Answers1

0

try to insert

if (row.IsNewRow) continue;

between foreach and switch

PrfctByDsgn
  • 1,022
  • 1
  • 14
  • 18