Darren Young
Darren Young

Reputation: 11090

C# Datagridview not adding new rows when databound

I have a databound dgv that contains combobox columns.

When the user selects an item from the combobox, then a new row is added as expected, and the values are added to a databound list. However, when I type a new value into the combobox, rather than select an option that is currently populated in the combobox, then no new row is added, although the value has still been added to the databound list.

I can't also add a new row programmatically as the dgv is databound.

Anybody any ideas?

Thanks.

Upvotes: 0

Views: 616

Answers (2)

GameAlchemist
GameAlchemist

Reputation: 19294

seems to be related to the way you 'confirm' what the user did. Maybe you use the 'SelectionChange' for the ComboBox, and that event does not fire if you enter a text, even if you press enter. handle the preview key pressed event, test if key was enter, and then handle this the same way you handle SelectionChanged.

Upvotes: 0

beac0n
beac0n

Reputation: 48

I don't know how you implemented this (can't hurt if you would post the code). But maybe you are using a wrong eventhandler? Maybe you could try to add the entered value to the combobox, and then change the index to the added value.

Upvotes: 0

Related Questions