Quantcast
Channel: Windows Forms Data Controls and Databinding forum
Viewing all articles
Browse latest Browse all 2535

.NET C# WinForm DataGridView: Issues with CellValueChanged event not triggered when in editmode of a cell and clicking a column header

$
0
0

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);}}

Viewing all articles
Browse latest Browse all 2535

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>