Detecting multiple items in a listbox - windows forms
Posted on 2004-10-03
I don't know why this isn't working for me, but it isn't , and I need some advice.
I have a windows forms app with a ListBox. The examples in the MSDN documentation say to load it up with ListItems - but I can't find a ListItem object in Windows Forms. I did find one in System.Web.UI.WebControls, so I added that, and build my ListBox like this:
Dim l As ListItem = New ListItem("MyItem")
I do this for each of several items, and that loads the listbox.
The listbox has the multiselect property on. So I select several items, and then try to detect them like this:
For Each li As ListItem In lstStyles.Items
If li.Selected Then
But it never detects a selected item. Never. So what gives? What am I doing wrong?