I have a datagridview with two columns. That is connected to a bindingsource.
Each column contains a single control, a checkbox.
I want that each time the user checks a checkbox, the checkbox in the other
column in the same row unchecks.
I am amazed I wasn't able to do something so apparently easy. But sometime I
do drown in a glass of water and that seems to be the case now.
I tried handling the CellContentClick event, however I couldn't get the
correct checkboxes values from the datagrid (ie, I check a box and on the
event the checkbox value is false ....).
Could anybody help with this please?
ClayB - 22 Mar 2007 22:48 GMT
Try handling these 2 events.
void dataGridView1_CellValueChanged(object sender,
DataGridViewCellEventArgs e)
{
int otherColumnIndex = (e.ColumnIndex == 1) ? 0 : 1;
dataGridView1[otherColumnIndex, e.RowIndex].Value = !
Convert.ToBoolean(dataGridView1[e.ColumnIndex, e.RowIndex].Value);
}
void dataGridView1_CellMouseUp(object sender,
DataGridViewCellMouseEventArgs e)
{
this.dataGridView1.EndEdit();
}
====================
Clay Burch
Syncfusion, Inc.