Click here to Skip to main content
15,888,968 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
VB6 ListBox Control.

I have a two ListBox, (list1 and list2)
When I change/Move the scroll(down/up) of list1 I want the list2 to scroll down/up same with the list1.
Posted
Comments
Sergey Alexandrovich Kryukov 17-Jun-11 15:32pm    
Such a bad design... and this is not a question.
--SA

I think you can handle the change but not scroll.

For example you have 2 listboxes with Customer IDs & Customer Names. The below code will select the item based on selected item of other listbox(I don't have VB 6 now :( )
VB
Private Sub listboxID_Click()
  listboxName.ListIndex = listboxID.ListIndex
End Sub
Private Sub listboxName_Click()
  listboxID.ListIndex = listboxName.ListIndex
End Sub
 
Share this answer
 
AFAIK you cannot synchronise the scrolling between two list boxes as there is no support for a scroll event. You can set the selections to run in tandem by catching the Change event.
 
Share this answer
 
Be aware to not link events to each other or you will find yourself in an infinite loop on on scroll events.

VB
Private Sub lstBox1_Scroll()
   lstBox2.TopIndex = lstBox1.TopIndex
End Sub


Regards
 
Share this answer
 
Comments
S Houghtelin 20-Jun-11 6:14am    
Care to elaborate as to why this was downvoted anyone? This is code from a VB6 project that works as the OP describes.

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