I'm trying to check cells from a DataGridViewCheckBoxColumn
.
I want to do it programmatically.
Here is my DatagridView
:
DataGridViewCheckBoxColumn dataChecked = new DataGridViewCheckBoxColumn(false);
this.dataGrid.Columns.Add(dataChecked);
My DataGrid
is using a DataSource
from sql but my CheckBoxColumn
doesn't. That column is just a way to know later when I have to add or remove some data to/from a container.
Container
DATA 1 Check
DATA 2 Uncheck
Container
DATA 1 Uncheck (remove)
DATA 2 Check (add)
I tried multiple things but nothing worked:
datagrid.Rows[1].Cells[5].Value = true;
datagrid.Rows[1].Cells[5].TrueValue = true;
DataGridViewCell chk = (DataGridViewCell)datagrid.Rows[1].Cells[5];
chk.Value = true;
I can tell if the cell is true or not but the CheckBox
is not checked...