vb.net - Get listbox SelectedItem string when using Display/Value Member -


I use the population of my listbox and value using the population. I know how to reach the value of the id (eg 134), but I would like to take an item string in any way that I can see on my linksbox when I choose it to reach the performance of member value?

  MyListBox.DisplayMember = "PicturePath" MyListBox.ValueMember = "id" MyListBox.DataSource = GetElementPics.ListPicsByElementId  

You can use:

  String = MyListBox.GetItemText (MyListBox.SelectedItem) as a dim picturePath  

From:

If the DisplayMember property is not specified, the value returned by GetItemText Toasting is the value of the method Otherwise, the law member DisplayMember is exhausted for the item specified in the item parameter Condition

Returns the string value specified in GetItemText returns an empty string. So if you want to handle it, then you should first check whether selectedIndex & lt; & Gt; -1 or is not a chosen anonymity .


Comments