I have a Datagrid, named ShowGrid. The first column of the Datagrid is a Checkbox column and I have a CheckboxHeader for Checking/Unchecking all the rows in the Datagrid.
I can also select particular row checkbox for a Buttonclick.After the Buttonclick, I disable the particular rows's Checkbox.
After this, if I check the checkboxHeader, the disabled checkbox is also getting checked. So how can I select only the enabled checkboxes on checking on CheckboxHeader. I have used the following code, But I get Object reference not set to an instance of an object.
exception.
foreach (DataGridViewRow row in ShowGrid.Rows)
{
if ((bool)row.Cells[0].Value == true && (bool)row.Cells[0].ReadOnly == false)
{
ShowGrid[0, row.Index].Value = ((CheckBox)ShowGrid.Controls.Find("checkboxHeader", true)[0]).Checked;
}
}
ShowGrid.EndEdit();