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 ?

Recommended Answers

All 2 Replies

dataGridView1.Rows[row_index].Cells[column_index].Value = true; check this link and this link for detailed view on checkbox column in DataGridView

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;
          }
      }
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.