I've tried for about an hour now just to figure out if a checkbox in a DataGridView control is checked or not. The Value field is always null, whether checked or not, and there is no Checked field like a Checkbox has. How can I detect if a cell is checked or not?
private void dataGridView1_CellContentClick(object sender, DataGridViewCellEventArgs e)
{
// Column 0 is the Checkbox column that I need.
if (e.ColumnIndex == 0)
{
// This gets the Checkbox cell.
DataGridViewCheckBoxCell cell = (DataGridViewCheckBoxCell)fileGrid.Rows[e.RowIndex].Cells[0];
// Always displays True.
MessageBox.Show((cell.Value == null) + "");
}
}