Damn listbox Madness (-please help me-)

If you need help with a project or need to know how to do something specific in VB.NET then please ask your questions in here.
Forum rules
Please LOCK your topics once you have found the solution to your question so we know you no longer require help with your query.
3 posts Page 1 of 1
Contributors
User avatar
muttley1968
Hardcore Programmer
Hardcore Programmer
Posts: 622
Joined: Thu Jun 17, 2010 11:54 pm

Hi i have to listboxes laid out like so


Richard Richard
Tom Tom

and so on all i want is if you click a name in one it will click it in the other i tried this code
Code: Select all
    Private Sub ListBox2_DoubleClick(ByVal sender As Object, ByVal e As System.EventArgs) Handles ListBox2.DoubleClick
        ListBox1.SelectedIndex = sender.Tag
    End Sub
and it does nothing only click staright to the top one and then dies wont work again wont do anything just stays their any ideas on how to change this so it will work please people
User avatar
CodenStuff
Site Admin
Site Admin
Posts: 4392
Joined: Tue Aug 04, 2009 1:47 am

Try
Code: Select all
    Private Sub ListBox2_DoubleClick(ByVal sender As Object, ByVal e As System.EventArgs) Handles ListBox2.DoubleClick
        ListBox1.SelectedItem = CType(sender, ListBox).SelectedItem
    End Sub
Welcome to CodenStuff.com Learn Code, Love Code. Thank you for being a member of the community.
User avatar
muttley1968
Hardcore Programmer
Hardcore Programmer
Posts: 622
Joined: Thu Jun 17, 2010 11:54 pm

that didnt work but i changed it to

Private Sub ListBox2_DoubleClick(ByVal sender As Object, ByVal e As System.EventArgs) Handles ListBox2.DoubleClick
ListBox1.SelectedIndex = CType(sender, ListBox).SelectedIndex
End Sub

and works great thanks Codenstuff
3 posts Page 1 of 1
Return to “Coding Help & Support”