Click here to Skip to main content
15,892,809 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Select Index In ListBox1 And Corresponding Index In ListBox2 Is Also Selected

eg:
listbox1 & listbox2 contain 6 items.

now i want select 4th item of listbox1, then listbox2 automatically change the selection to 4th item of listbox2.
can u help me.
Posted
Updated 9-Dec-11 19:04pm
v2
Comments
Abhinav S 10-Dec-11 1:04am    
Code tags removed.

Try this code :
VB
Private Sub ListBox1_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ListBox1.SelectedIndexChanged
        If ListBox1.SelectedIndex < ListBox2.Items.Count Then ListBox2.SelectedIndex = ListBox1.SelectedIndex
End Sub
 
Share this answer
 
Comments
hari301 10-Dec-11 5:23am    
thanks.. Up selection only working.. i need down selection also.
SQL
Private Sub ListBox2_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ListBox2.SelectedIndexChanged
       ListBox2.SelectedIndex = ListBox1.SelectedIndex
   End Sub
 
Share this answer
 
Comments
hari301 10-Dec-11 5:24am    
so many times i tried this code... but no improvement

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900