adzinthepub
07-18-2003, 08:53 AM
is there any way to make two list boxes synchronised with each other. eg if you scroll down 5 items on the one list box the second list box scrolls down the same number of items.
thanks
thanks
make two list boxes scroll togetheradzinthepub 07-18-2003, 08:53 AM is there any way to make two list boxes synchronised with each other. eg if you scroll down 5 items on the one list box the second list box scrolls down the same number of items. thanks Squishy 07-18-2003, 08:59 AM Private Sub List1_KeyDown(KeyCode As Integer, Shift As Integer) On Error Resume Next '40 = down, 38 = up If KeyCode = 40 Then List2.ListIndex = List2.ListIndex + 1 ElseIf KeyCode = 38 Then List2.ListIndex = List2.ListIndex - 1 End If End Sub Adjust the code for the other box and it should work. Mad_Kitten 07-18-2003, 09:04 AM that code would work, it the user scroll with the arrow keys but what about the mouse. SpaceFrog 07-18-2003, 09:05 AM try same code on different eevent ... Squishy 07-18-2003, 09:07 AM good point...guess my previous thoughts go back up... Keep track of the ListIndex value of both listboxes, in the Click event of the listboxes (I think it's also executed when the seletion changes w/ keyboard), determine if the selection has scrolled up or down, and adjust the ListIndex of the other box accordingly. adzinthepub 07-18-2003, 09:14 AM how do i program the code to say the user has scrolled up or down thanks Squishy 07-18-2003, 09:17 AM Say the user clicked in List1. In the click event, retrieve the new ListIndex of List1. Determine if the ListIndex increased or decreased; an increase means the user scrolled down. Use List2.ListIndex = List2.ListIndex + (or -) the difference. Update the variables that keep track of the ListIndex values. Add some error handlers to keep the index within a valid range. adzinthepub 07-18-2003, 09:22 AM thanks a lot ImmortalWarrior 07-18-2003, 09:47 AM That's a fair bit of effort considering the List_Click event fires whether you use the mouse or the arrow keys... Why not just use: Private Sub List1_Click() List2.ListIndex = List1.ListIndex End Sub Private Sub List2_Click() List1.ListIndex = List2.ListIndex End Sub :-\ Matt Mad_Kitten 07-18-2003, 10:33 AM you can't use that code, because when the user scrolls the listindex isn't changed. ImmortalWarrior 07-18-2003, 10:45 AM Ah... you're scrolling up and down the object with scroll bars not selecting different items in the list. Must admit, I was slightly taken aback by the fact no-one had picked up on that, but that would explain why... :-\ Matt Lar_19 07-18-2003, 01:45 PM Do both list boxes have the same list count? If so you could do something like this...Private Sub List1_Scroll() List2.TopIndex = List1.TopIndex End Sub Private Sub List2_Scroll() List1.TopIndex = List2.TopIndex End Sub Squishy 07-18-2003, 05:41 PM hm...I was thinking too much ( * * * * coffee)...since its always synchronized, the ListIndex should be the same in both listboxes :huh: ....then the code from ImmortalWarrior would work...screw coffee, goin back to the mountain dew... |
EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum