DataGridView with CheckBox cell issue

I have a DataGridView with a DataGridViewCheckBoxColumn column that binds to a list. The problem is that the boolean value for this flag is not updated when the flag is checked / not checked, but after the CellLeave event, in other words, after the cell loses focus. I want this property to be updated immediately after checking / unchecking. There, the CurrentCellDirtyStateChanged event occurs, which fires immediately after check / uncheck, so I can use it to update manually. Is there a better way to do this?

+7
c # data-binding winforms
source share
2 answers

You can listen to the CurrentCellDirtyStateChanged event and force the commit to commit:

void dataGridView1_CurrentCellDirtyStateChanged(object sender, EventArgs e) { if (dataGridView1.IsCurrentCellDirty) { dataGridView1.CommitEdit(DataGridViewDataErrorContexts.Commit); } } 
+13
source share
0
source share

All Articles