Home All Groups Group Topic Archive Search About

Setting the selected item of a listbox when only one the text value

Author
15 May 2009 8:24 PM
ChunkyMonkey
Hi,

As simple as I am sure this is, I am not able to get something the work.

I have a text value (string), and I want to find an item in a listbox where
the item matches the string I have, and then set that item as the selected
item.

How is this done ?


Thanks!!

Author
15 May 2009 9:35 PM
roidy
Dim item As Integer = ListBox1.FindString(string)
ListBox1.SelectedIndex = item

where 'string' is the string you want to find.

Rob

Show quoteHide quote
"ChunkyMonkey" <Chu***@Monkey.com> wrote in message
news:ei6otsZ1JHA.1900@TK2MSFTNGP04.phx.gbl...
> Hi,
>
> As simple as I am sure this is, I am not able to get something the work.
>
> I have a text value (string), and I want to find an item in a listbox
> where the item matches the string I have, and then set that item as the
> selected item.
>
> How is this done ?
>
>
> Thanks!!
>