D
DrDBF
I understand that the Value put into a DataGridViewComboBoxCell has to be a
member of the Items list or an exception is thrown.
I also understand that you can override that exception by handling the
DataError event and just doing nothing in the circumstance that caused the
error.
Here's my situation: I would like to allow the user to EITHER select an item
from the ComboBox (in a DataGridView) OR type in a new value of their own.
I've handled the EditingControlShowing event to change the DropDownStyle of
the editing control to DropDown (rather than DropDownList). This allows me to
type something new into the edit box of the ComboBox.
Then I handled the CellEndEdit event to snag the Text from the editing
ComboBox control. I take that Text and put it into the Value of the
DataGridViewComboBoxCell. This triggers the exception.
If I override that exception, things move along OK, except that that cell
now takes the value of the first item in the ComboBox Items list.
Is there a way to force the ComboBox to accept the new value?
Or perhaps a different way to work around this:
Is there a way to have the DataGridView column be of the Text type, but
attach a ComboBox instead of a TextBox for editing. Then take whatever the
Text value is from the ComboBox EditingControl and put that into the
DataGridViewTextBoxCell?
I hope: 1) this makes sense, and 2) someone out there knows how to pull this
off.
Thanks.
member of the Items list or an exception is thrown.
I also understand that you can override that exception by handling the
DataError event and just doing nothing in the circumstance that caused the
error.
Here's my situation: I would like to allow the user to EITHER select an item
from the ComboBox (in a DataGridView) OR type in a new value of their own.
I've handled the EditingControlShowing event to change the DropDownStyle of
the editing control to DropDown (rather than DropDownList). This allows me to
type something new into the edit box of the ComboBox.
Then I handled the CellEndEdit event to snag the Text from the editing
ComboBox control. I take that Text and put it into the Value of the
DataGridViewComboBoxCell. This triggers the exception.
If I override that exception, things move along OK, except that that cell
now takes the value of the first item in the ComboBox Items list.
Is there a way to force the ComboBox to accept the new value?
Or perhaps a different way to work around this:
Is there a way to have the DataGridView column be of the Text type, but
attach a ComboBox instead of a TextBox for editing. Then take whatever the
Text value is from the ComboBox EditingControl and put that into the
DataGridViewTextBoxCell?
I hope: 1) this makes sense, and 2) someone out there knows how to pull this
off.
Thanks.