|
-
Aug 27th, 2000, 05:41 PM
#1
Thread Starter
Hyperactive Member
Lets say i have 2 list. they are right next to eachother, and say on the first list i click the 5th item. how can i highlight the 5th item in the second list. and vice versa.
also how can i change the scroll bar thing.
-
Aug 27th, 2000, 05:51 PM
#2
Addicted Member
Hi,
Try This:
Code:
Private Sub List1_Click()
Dim i As Integer
For i = 0 To List1.ListCount - 1
If List1.Selected(i) Then List2.Selected(i) = True
Next i
Reverse List1 and List2 around in the code to make it work the other way.
Not sure about the scrollbar though!! 
hope this helps
Shaun
Web/Application Developer
VB6 Ent (SP5), Win 2000,SQL Server 2000
-
Aug 27th, 2000, 05:53 PM
#3
Add 2 Listboxes to a Form as a Listbox Control Array:
Code:
Private Sub Form_Load()
'Generate some Dummy List Items
Dim lIndex As Long
For lIndex = 1 To 100
lstLists(0).AddItem "Item " & Right("000" & lIndex, 3)
lstLists(1).AddItem "Item " & Right("000" & lIndex, 3)
Next
End Sub
Private Sub lstLists_Click(Index As Integer)
Static bAligning As Boolean
Dim lOtherList As Long
'Use a Static Boolean Var to prevent recursion (setting the ListIndex triggers the "Click" Event)
If bAligning Then Exit Sub
'Flag that we're performing an Alignment operation
bAligning = True
'Get the Index of the "Other" Listbox
lOtherList = (Index + 1) Mod 2
'If there is a matching Item in the Other Listbox...
If lstLists(lOtherList).ListCount >= lstLists(Index).ListIndex Then
'Select the same Item...
lstLists(lOtherList).ListIndex = lstLists(Index).ListIndex
'Make the TopIndex Match too (Keeps both aligned)
lstLists(lOtherList).TopIndex = lstLists(Index).TopIndex
End If
'Reset the Alignment flag
bAligning = False
End Sub
-
Aug 27th, 2000, 06:41 PM
#4
If you also want them to scroll simultaniously add the following code in the listbox scroll event:
Code:
Private Sub List1_Scroll()
List2.TopIndex = List1.TopIndex
End Sub
Private Sub List2_Scroll()
List1.TopIndex = List2.TopIndex
End Sub
This code might look like it causes recursion but it will not.
Good luck!
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|