How to determine the items selected in ListBox Control

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I know how to do it in VB6, but that doesn't work in .NET. I am trying to
select single or multiple items to load into a collection.
 
I presume you are using winforms so have a look at the properties selecteditems and selectedindices

HTH

Ollie Riches
 
I am, but i was also loading items into the ListBox from a datatable. I am
putting the selected items from the ListBox into a Collection
("App.ProdSel"). I found this code which worked for me.

Dim drvListItem as DataRowView

For Each drvListItem In lstProduct.SelectedItems
App.ProdSel.Add(drvListItem(lstProduct.DisplayMember))
Next

I didn't realize that when you load items into a ListBox or ComboBox from a
datatable that they become DataRowViews and that you can access them that
way. Found the right code just a few minutes before you e-mailed me.

Thank you for your help.
 
Back
Top