NOVATO EN PROGRAMACION-AYUDA
SOY UN NOVATO EN EL MUNDO DE VB. AGRADECERIA QUE ALGUIEN ME AYUDARA. LA DUDA QUE TENGO ES: ¿COMO SINCRONIZAR LAS BARRAS DE SCROLL DE VARIOS LISTBOX?
GRACIAS
GRACIAS
Te pongo un ejemplo, para verlo crea un nuevo proyecto
e inserta 3 listbox(List1, List2 y List3) en el formulario,
después copia el siguiente código:
Private Sub Form_Load()
Dim i As Integer
For i = 1 To 30
List1.AddItem "Elemento " & Str(i)
List2.AddItem "Elemento " & Str(i)
List3.AddItem "Elemento " & Str(i)
Next i
End Sub
Private Sub List1_Click()
List2.ListIndex = List1.ListIndex
List3.ListIndex = List1.ListIndex
End Sub
Private Sub List2_Click()
List1.ListIndex = List2.ListIndex
List3.ListIndex = List2.ListIndex
End Sub
Private Sub List3_Click()
List1.ListIndex = List3.ListIndex
List2.ListIndex = List3.ListIndex
End Sub
Private Sub List1_Scroll()
List2.TopIndex = List1.TopIndex
List3.TopIndex = List1.TopIndex
End Sub
Private Sub List2_Scroll()
List1.TopIndex = List2.TopIndex
List3.TopIndex = List2.TopIndex
End Sub
Private Sub List3_Scroll()
List1.TopIndex = List3.TopIndex
List2.TopIndex = List3.TopIndex
End Sub
Si tienes muchos te aconsejo que hagas un array con
de controles(ListBox claro), escribirás menos código.
De todas formas me parece que lo que intentas hacer
quedaría mucho mejor con un control msFlexGrid.
e inserta 3 listbox(List1, List2 y List3) en el formulario,
después copia el siguiente código:
Private Sub Form_Load()
Dim i As Integer
For i = 1 To 30
List1.AddItem "Elemento " & Str(i)
List2.AddItem "Elemento " & Str(i)
List3.AddItem "Elemento " & Str(i)
Next i
End Sub
Private Sub List1_Click()
List2.ListIndex = List1.ListIndex
List3.ListIndex = List1.ListIndex
End Sub
Private Sub List2_Click()
List1.ListIndex = List2.ListIndex
List3.ListIndex = List2.ListIndex
End Sub
Private Sub List3_Click()
List1.ListIndex = List3.ListIndex
List2.ListIndex = List3.ListIndex
End Sub
Private Sub List1_Scroll()
List2.TopIndex = List1.TopIndex
List3.TopIndex = List1.TopIndex
End Sub
Private Sub List2_Scroll()
List1.TopIndex = List2.TopIndex
List3.TopIndex = List2.TopIndex
End Sub
Private Sub List3_Scroll()
List1.TopIndex = List3.TopIndex
List2.TopIndex = List3.TopIndex
End Sub
Si tienes muchos te aconsejo que hagas un array con
de controles(ListBox claro), escribirás menos código.
De todas formas me parece que lo que intentas hacer
quedaría mucho mejor con un control msFlexGrid.
