Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can a combobox control hosted in DataGridView cell ask to end edit?

I have a combobox control hosted in a unbound DataGridView control. When the user selects an item (or types an entry and hits enter) I want it to apply the change and come out of edit mode.

Is this possible?

like image 732
McBainUK Avatar asked Apr 07 '09 11:04

McBainUK


2 Answers

On the CurrentCellDirtyStateChanged event of your DataGridView, you can call the following code:

myDataGridView.EndEdit(DataGridViewDataErrorContexts.Commit)
like image 148
Meta-Knight Avatar answered Oct 18 '22 18:10

Meta-Knight


Also you can do :

 datagridview1.CommitEdit(DataGridViewDataErrorContexts.Commit);

if you want to not end edit and your value to be committed.

like image 45
mesteru_vali Avatar answered Oct 18 '22 19:10

mesteru_vali