| Control two or more ListBox with one Scroolbar Private Sub Command5_Click() MyList(0).AddItem "33", 0 'adds Items to the Lists and then MyList(1).AddItem "77", 0 MyList(2).AddItem "270", 0 MyList(3).AddItem "Moldy Green", 0 PopulateLists 'refills the front list boxes End Sub Private Sub Form_Load() Dim X As Long 'Fills the Front Listboxes with Nothing 'so that they are easyer to deal with For X = 0 To 11 MyListFront(0).AddItem "" MyListFront(1).AddItem "" MyListFront(2).AddItem "" Next X PopulateLists 'then fills them with the Background data End Sub Private Sub MyList_Click(Index As Integer) If MyList(3).ListIndex - MyList(3).TopIndex >= 0 And MyList(3).ListIndex - MyList(3).TopIndex < 12 Then MyListFront(0).Selected(MyList(3).ListIndex - MyList(3).TopIndex) = True MyListFront(1).Selected(MyList(3).ListIndex - MyList(3).TopIndex) = True MyListFront(2).Selected(MyList(3).ListIndex - MyList(3).TopIndex) = True Else MyListFront(0).ListIndex = -1 'If the selected item in the right list is with in MyListFront(1).ListIndex = -1 'the scope of the Front Lists then it selectets them MyListFront(2).ListIndex = -1 End If End Sub Private Sub MyList_Scroll(Index As Integer) MyList_Click 3 'Uses Current code to do scroll event PopulateLists End Sub Private Sub MyListFront_Click(Index As Integer) Dim X As Long If MyList(2).ListCount > 0 Then 'When Clicked selects all lists If MyListFront(Index).ListIndex >= 0 Then MyListFront(0).Selected(MyListFront(Index).ListIndex) = True MyListFront(1).Selected(MyListFront(0).ListIndex) = True MyListFront(2).Selected(MyListFront(0).ListIndex) = True MyList(3).Selected(MyListFront(Index).ListIndex + MyList(3).TopIndex) = True End If End If End Sub Sub MyLists_Click(Index As Integer) Dim X As Byte Dim TowerVar As String Dim LevelVar As String If MyList(Index).ListCount > 0 Then 'When Clicked selects all lists If MyList(Index).ListIndex - MyList(Index).TopIndex >= 0 And MyList(Index).ListIndex - MyList(Index).TopIndex < 12 Then MyListFront(0).Selected(MyList(3).ListIndex - MyList(3).TopIndex) = True MyListFront(1).Selected(MyList(3).ListIndex - MyList(3).TopIndex) = True MyListFront(2).Selected(MyList(3).ListIndex - MyList(3).TopIndex) = True Else MyListFront(0).ListIndex = -1 MyListFront(1).ListIndex = -1 MyListFront(2).ListIndex = -1 End If End If End Sub Private Sub MyLists_Scroll(Index As Integer) Dim X As Byte For X = 0 To 2 MyList(X).TopIndex = MyList(Index).TopIndex Next X If MyList(2).ListIndex - MyList(2).TopIndex < 0 Or MyList(2).ListIndex - MyList(2).TopIndex > 7 Then MyListFront(0).ListIndex = -1 MyListFront(1).ListIndex = -1 Else MyListFront(0).Selected(MyList(2).ListIndex - MyList(2).TopIndex) = True MyListFront(1).Selected(MyList(2).ListIndex - MyList(2).TopIndex) = True End If PopulateLists End Sub Sub PopulateLists() Dim X As Long For X = 0 To 11 MyListFront(0).List(X) = MyList(0).List(X + MyList(3).TopIndex) MyListFront(1).List(X) = MyList(1).List(X + MyList(3).TopIndex) MyListFront(2).List(X) = MyList(2).List(X + MyList(3).TopIndex) Next X MyLists_Click 3 End Sub |
One Scroolbar |
Express News India | Freelance ecommerce web development India