dseaver
IS-IT--Management
- Jul 13, 2006
- 467
I have a Check Box Column that i want to have only one itme checked anytime. The function I wrote works, but it doesn't take affect immediately, I have to click away from the cell before the check mark changes. Is there away for the value to change immediately? Here is my eventhandler
The event is DataGridView.CellValueChanged
Code:
void AllowOneCheckInColumn(object sender, DataGridViewCellEventArgs e)
{
if (Convert.ToBoolean(datagrid[e.ColumnIndex, e.RowIndex].Value))
{
foreach (DataGridViewRow row in datagrid.Rows)
{
if (row.Index != e.RowIndex)
{
row.Cells[datagrid.Columns[e.ColumnIndex].Name].Value = false;
}
}
}
}