Victor Chelaru
Victor Chelaru

Reputation: 4837

DataGridView cell doesn't raise CellEndEdit until new cell is selected

I'm creating a DataGridView which is displaying a column of bool values. I'm using the visual designer in Visual Studio for making winforms and have added a column which has its "ColumnType" set to "DataGridViewCheckBoxColumn" so that check boxes appear instead of text fields.

I also do the following:

ElementDataGrid.CellEndEdit += new DataGridViewCellEventHandler(OnCellValueChanged);

The problem I'm seeing is that if I check the checkbox at runtime by clicking on it, the OnCellValueChanged doesn't get raised (verified both by my program not responding, as well as breakpoints not being hit). Then as soon as I select a different cell with the mouse, the event gets raised. It's as if the CellEndEdit doesn't get raised until the cell gets deselected.

I'd like the rest of my application to immediately respond as soon as the user checks the checkbox and not have to wait for the user to deselect it. Is there a different event I could use? I've also tried: * CellValidating * CellValidated * CellValueChanged But all seem to work the same - they require the user to select a different cell.

Upvotes: 1

Views: 4348

Answers (1)

Binil
Binil

Reputation: 6583

try using
DataGridView.CurrentCellDirtyStateChanged Event, which Occurs when the state of a cell changes in relation to a change in its contents.

Upvotes: 2

Related Questions