When I change a value in a DataGridViewComboBoxCell the new value is not immediately applied until that cell leaves focus.
Is there a way to have the new value applied immediately?
When I change a value in a DataGridViewComboBoxCell the new value is not immediately applied until that cell leaves focus.
Is there a way to have the new value applied immediately?
If you handle the EditingControlShowing
event on the DataGridView, you can attach an event handler to the underlying ComboBox's SelectedIndexChanged
event (or SelectedValueChanged
, or any other ComboBox event). It will fire immediately whenever the ComboBox value changes, and you can do whatever you want with the new value.
There's example code for this in the MSDN docs for DataGridViewComboBoxEditingControl.
DataGridView.CommitEdit Method
This might be of some use to you as well. Handle the CurrentCellDirtyStateChanged event, check for Dirty, and Commit the edit. Then you can use the CurrentCell property to access the value that was selected (assuming it was validated).