Click here to Skip to main content
15,916,846 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I am trying to get combobox valuemember value into a string, when drawing items in a combobox.

To get the displaymember, I can use below code:

string displayMemberText = ((ComboBox)sender).GetItemText(((ComboBox)sender).Items[e.Index]);


But how can I do the same, if I want to get the valuemember into a string?

I want to use the value, to compare valuemember with another string.

What I have tried:

I have tried everything, but can't figure out how to replace "GetItemText" with "GetItemID".
Posted
Updated 26-Jan-19 0:20am

1 solution

Found a solution:

string valueMemberText = ((DataRowView)((ComboBox)sender).Items[e.Index])[0].ToString();
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900