i use VB6 enterprize edition. How would one go about linking the vscroll bars for adjacent listboxes so that, if one is scrolled, the two others slide up and down too? 开发者_如何学运维The object is to keep information displayed in the lists side by side. I have tried setting the listindex property of the two other lists equal to the first one's listindex using the click event. It works after a fashion, but is a less than ideal solution. If one clicks on an item in the first list, the listindex for the other two do appear on the screen, but they are not really linked or displayed side by side. I noticed a scroll event but cannot find any matarial on using this event in any of my VB books. Any help would be appreciated.
Handle the scroll event for the listboxes. This will fire whenever the listbox is scrolled.
In the event handler, set the TopIndex property for the other listboxes equal to the TopIndex of the scrolled listbox.
I found this code for 2 listboxes on a newsgroup post. A module-level variable is used to prevent recursion: setting the TopIndex from code might fire the Scroll event again.
Dim m_NoScroll As Boolean ''module-level flag var
Private Sub List1_Scroll()
If Not m_NoScroll Then
m_NoScroll = True
List2.TopIndex = List1.TopIndex
m_NoScroll = False
End If
End Sub
Private Sub List2_Scroll()
If Not m_NoScroll Then
m_NoScroll = True
List1.TopIndex = List2.TopIndex
m_NoScroll = False
End If
End Sub
精彩评论