Implementing Change Selection for DataGridViewComboBoxCell

When I change a value in a DataGridViewComboBoxCell, the new value is not applied immediately until this cell leaves focus.

Is it possible to immediately apply the new value?

+6
winforms combobox datagridview
source share
3 answers

If you are handling the EditingControlShowing event in a DataGridView, you can attach an event handler to the ComboBox SelectedIndexChanged base 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.

Here is the sample code for this in the MSDN docs for DataGridViewComboBoxEditingControl .

+8
source share

Method DataGridView.CommitEdit

This may come in handy for you too. Handle the CurrentCellDirtyStateChanged event, check the "Dirty" and "Finish Editing" boxes. Then you can use the CurrentCell property to access the selected value (provided that it has been confirmed).

+4
source share
 DataGridView1.EndEdit() 

Ignore this text, the response must be at least 30 characters

0
source share

All Articles