nchantim
asked on
"Winforms ListItem" - or "how to Select items in a Listbox"
I'm going batty trying to programatically highlight items allready in a listbox in a windows app.
I temporarily discovered ListItem, only to realize it's a webforms thing.
What I want it something like this, but that works in a windows app:
Sub HighlightItem (strLine)
Dim lstObj as ListItem
For Each lstObj In Me.lstInstrumentTypes.Item s
If lstObj.Text = strLine Then
lstObj.Selected = True
End If
Next
End Sub
Yes, I know about the ListView control.
I temporarily discovered ListItem, only to realize it's a webforms thing.
What I want it something like this, but that works in a windows app:
Sub HighlightItem (strLine)
Dim lstObj as ListItem
For Each lstObj In Me.lstInstrumentTypes.Item
If lstObj.Text = strLine Then
lstObj.Selected = True
End If
Next
End Sub
Yes, I know about the ListView control.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
I tried my code with the listbox, but of course, ListItem is in Web.UI.WebControls.ListIte
and Vb.net seems to dislike trying to convert the type.
I think I may end up using a ListView in Details mode - that seems to work quite well after all.
Oddly enough, I've been using VB since v3, and never had a program try to highlight a list box item before!