I have a Winforms DataGridView in my application.
I've two checkbox columns along with 5 other columns from the database. These two checkbox columns are added usng DataGridViewCheckBoxColumn.
When the user clicks on the 2nd checkbox, I need to show a message to the user if the first checkbox is not checked for that row.
How do I go about this? I tried this,but the cell value is coming as null. What am i doing wrong?
private void dgTest_CellClick(System.Object sender, DataGridViewCellEventArgs e)
{
DataGridViewCheckBoxCell officialCbCell = row.Cells[1] as DataGridViewCheckBoxCell;
DataGridViewCheckBoxCell includeCbCell = row.Cells[0] as DataGridViewCheckBoxCell;
if (officialCbCell != null)
{
if (officialCbCell.Value != null && (bool)officialCbCell.Value == true)
{
if (includeCbCell != null && (bool)includeCbCell.Value == false)
{
MessageBox.Show("INVALID");
}
}
}
}
Thanks.