McBainUK
McBainUK

Reputation: 432

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?

Upvotes: 7

Views: 1961

Answers (2)

mesteru_vali
mesteru_vali

Reputation: 11

Also you can do :

 datagridview1.CommitEdit(DataGridViewDataErrorContexts.Commit);

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

Upvotes: 1

Meta-Knight
Meta-Knight

Reputation: 17855

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

myDataGridView.EndEdit(DataGridViewDataErrorContexts.Commit)

Upvotes: 8

Related Questions