Quantcast
Channel: VBForums - Visual Basic .NET
Viewing all articles
Browse latest Browse all 27417

VS 2012 2 Listboxs click 1 to select an item in the other

$
0
0
I have two listboxs and i want to click on an Item in listbox1, which will contain names of people and once its selected, it will check listbox2 to see if it has any matching names from listbox1 in listbox2. And if it does, I want listbox2 to automatically set the matching item in listbox2 to be selected. How would I do that???

Code:

        'Whats in listbox1?
        Dim Name As String = ListBoxName.SelectedItem.ToString()
        'Now does this match or are alike?
        Dim index As Integer = ListBoxAddress.FindString(Name)
        'If the item was not found in ListBox2 we do this.
        If index = -1 Then
            MessageBox.Show("Item is not available in ListBox2")
        Else
            ListBoxAddress.SetSelected(index, True)
        End If

I wrote that but find string is not useful... I was trying to use ListBoxAddress.contains but I'm getting tired and cant get my head around it. Any helps thanks.

Viewing all articles
Browse latest Browse all 27417

Latest Images

Trending Articles



Latest Images

<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>