Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Linking scroll bars on adjacent listboxes together

Tags:

vb6

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.

like image 338
user512163 Avatar asked Nov 18 '10 13:11

user512163


1 Answers

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 
like image 77
MarkJ Avatar answered Oct 20 '22 08:10

MarkJ