I have DataGridView bound by a datatable i have checkboxes to the same.
I want to navigate or loop through the the datagridview and check mark these checkboxes ,Below is the syntax i use .
foreach(DataGridViewRow dr in dgvColumns.Rows)
{
DataGridViewCheckBoxCell checkCell =
(DataGridViewCheckBoxCell)dr.Cells["CheckBoxes"];
checkCell.Value=1;
//Also tried checkCell.Selected=true;
//Nothing seems to have worked.!
}
The following worked for me, it checked the checkboxes perfectly :)
foreach (DataGridViewRow row in dgvDataGridView.Rows)
{
((DataGridViewCheckBoxCell)row.Cells[0]).Value = true;
}