I have a little problem.
Column 6 (for example) have a ColStyles ComboBox.
The Datasource for this Column is an Arraylist. This Arraylist contains a object with two values (id and text).
now the problem ;-)
Set the Datasource, Dosplaymember and Valuemember.
mygrid.ColStyles(6).DataSource = MyArraylist
mygrid.ColStyles(6).DisplayMember = "text"
mygrid.ColStyles(6).ValueMember = "id"
the combobox shows me now the Member "text" OK! it work. but if i change the comboboxitem, the valuemeber is every time "id".
selection --> car ("text") --> return "id" and not (2)
selection --> plane("text") --> return "id" and not (3)
can you help me?
thanks a lot.
(sorry! my english is not so beautiful)
When you want to determine the value that was selected you need to check the style.CellValue property, not the style.ValueMember.
style.CellValue will have the id value (2)
style.FormattedText will have text (e.g. "plane")
BJBoris JansenOctober 21, 2003 03:27 AM UTC
Thanks, but is doesn`t work. if i ask for the cellvalue, the grid returns me the text inside the cell (e.g. "bike") but not the id.
Thanks a lot.
AdministratorOctober 21, 2003 08:00 AM UTC
It should ...
Try take a look at the sample in Grid\Samples\CellTypes\ComboBoxCells.
You can modify it and send me your code changes. Then I can take a look what might be wrong.
AdministratorOctober 21, 2003 08:20 AM UTC
Attached is a minimal sample that I think is set up the way you described. If you set a value in cell 1,1, and then click the button, it seems to chow the CellValue and FormattedText as expected. What are you doing differently?