Link to home
Start Free TrialLog in
Avatar of oak29
oak29

asked on

Datagridview ComboboxColumn value

I have a datagridview comboboxcolumn that has a valuemember and a displaymember.  The valuemember is saved in the database and I need to use displaymember for a calculation.  All I can seem to get is the valuemember for the database.  

Somevariable = CDbl(.Cells("column_name").Value.ToString) --> This gets me the valuemember.  What can I do to get the Displaymember and assign its value to a variable?
Avatar of 50cal
50cal
Flag of United Kingdom of Great Britain and Northern Ireland image

ASKER CERTIFIED SOLUTION
Avatar of Zhaolai
Zhaolai
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
DisplayMember will give you the name of the property (or column) in the datasource that the control is bound to.

To get the Text that is displayed in the cell, you could use the Value property and do a lookup for the corresponding Display Value in the datasource.

e.g.

Somevariable = CDbl(.Cells("column_name").Value.ToString)
''lookup the Display value in the datasource using the Value
Dim dr As DataRow = ds.Tables.Item(0).Rows.Find(Somevariable)
Dim DisplayValue As String = dr.Item("SomeColumn")