Long time no post! I hope everyone's well!

I'd appreciate some input here on this one...

I still, even after reading the MSDN documentation on the Listbox and ListControls, have no clue what exactly these properties are for.

I'm assuming the SelectedValue property, when accessed, returns the "value" of the item in the list that is selected, like the listbox might show employee names, but the real "value" of the items is the employee number or something; I think I get that, but ValueMember?

I thought that the ValueMember was used if you bound data to the listbox, the ValueMember was the column (or whatever) that the SelectedValue got it's value from, but that doesn't seem to be true, considering in a databound listbox, you can select a column name for the SelectedValue property and it works, even if you leave the ValueMember set to "None"

Could someone explain what these two properties really are, in simplistic terms, but not too simplistic, the MSDN site achieves that already.

6 Years
Discussion Span
Last Post by phoenix911

As far as I understand it.

The values set in the ValueMember is the value being returned after selecting something in the listbox. as you said, the If it displays employees, it doesnt mean the value is the employee names, more rather the employee IDs.

So when binding the data, you can set the DataMember(what is seen) and the ValueMember(the value behind).

and you are correct about the SelectedValue. It just means that you want the value of the SelectedItem in the listbox

Correct me if I am wrong.

Edited by phoenix911: n/a


I still don't get it. Does that mean a item in the listbox can have 3 values? A displayed value, a selected value and a value member value?

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.