Reputation: 2517
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?
Upvotes: 6
Views: 10581
Reputation: 1165
DataGridView1.EndEdit()
Ignore this text, answer must be at least 30 characters
Upvotes: 0
Reputation: 1854
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).
Upvotes: 5
Reputation: 2767
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.
Upvotes: 8