Basically, I have a DataGridView = grid
, and I've hooked the following events:
CellDirtyStateChanged
CellValueChanged
CellValidating
When I edit a cell (under DataGridViewColumn.ValueType == typeof(uint)
), and then click on another cell, then theCellValueChanged
event is fired as expected.
However, when I edit a cell, and I click on a column header (while the cell was in edit mode), then theCellValueChanged
event is not fired which is NOT expected.
So, anyone expert know why is this? and how to fire the CellValueChanged
event on the 2nd scenario?
NOTE:
- the cell is a
DataGridViewTextBoxCell
object - the cell's ValueType is
typeof(uint)
the
CellDirtyStateChanged
event is fired but it's not used in case of aDataGridViewTextBoxCell
. However, it's used when a cell is a comboBox cell, to simulate (SelectedIndexChanged
Event), for example:publicvoidGrid_CellDirtyStateChanged(Object sender,System.EventArgs e){DataGridView gridSender = sender asDataGridView;if(gridSender.IsCurrentCellDirty&& gridSender.CurrentCell!=null&& gridSender.CurrentCellisDataGridViewComboBoxCell){// This fires the cell value changed handler below gridSender.CommitEdit(DataGridViewDataErrorContexts.Commit);}}