I have a comboBox with ValueMember = ID and DisplayMember = Name. I need the value that is associated with that name so I do something like this:
if (cboTypeOfMaterial.SelectedIndex != -1) { string temp = cboTypeOfMaterial.SelectedValue.ToString(); //More code here... } Which returns the ID value as a string. For example - "7".
If I try :
if (cboTypeOfMaterial.SelectedIndex != -1) { string temp = cboTypeOfMaterial.DisplayMember.ToString(); //More code here... } I get the string Name which is the key.
And what I need is to get the value of the selected element's Name