0

I have a column in the datagrid view which i would like to make the value of the checkbox true. Do you no how to do so ?

3
Contributors
2
Replies
3
Views
6 Years
Discussion Span
Last Post by Mitja Bonca
0

If you want to set all to true then you can do:

foreach (DataGridViewRow row in dataGridView1.Rows)
      {
        DataGridViewCheckBoxCell chk = row.Cells[0] as DataGridViewCheckBoxCell;
        if (Convert.ToBoolean(chk.Value) == false)
            chk.Value = true;
      }

If you want to set for a specific row:

foreach (DataGridViewRow row in dataGridView1.Rows)
      {
          if(row.index == dataGridView1.CurrentCell.RowIndex)
          {
              DataGridViewCheckBoxCell chk = row.Cells[0] as DataGridViewCheckBoxCell;
              if (Convert.ToBoolean(chk.Value) == false)
                  chk.Value = true;
          }
      }
This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.