I have found a few samples of using a combobox in a Datagrid on the Web
(Windows Forms). While these examples work well for what they do, I need
more functionality, and I'd like some advice on the best way to implement it
(if it hasn't already been implemented, that is)...
Here's my situation:
-I have an ArrayList of Items that need to be bound to the combobox. The
ArrayList contains data like this:
1, Green
3, Yellow
7, Red
-The underlying Datagrid field should display the text value but the numeric
value will actually be written back to the database.
I've been trying to come up with the best way to do this, and so far my
ideas mostly entail adding a property to the class being used to implement
the combobox in datagrid, and setting it to the numeric value of the
selected combobox item. My other option was to load the lookup table values
into Hashtables of the form:
htColor ("Green") = 1
htColor ("Yellow") = 3
htColor ("Red") = 7
And then retrieve the Hashtable values before writing back to the database.
Because of design requirements, the Datagrid is *not* bound to the
Datasource - it is populated via a DataTable generated at run-time.
I just wanted to make sure I was on the right track here, if anyone knows of
this being done somewhere already (I'm sure I'm not the first person to
encounter this), or if I'm way off base with this one and obviously
insane...
Thanks.