ListBox1.TopIndex = 2
ListBox1.Selected(ListBox1.TopIndex) = True
Option Explicit Private Sub CommandButton1_Click() ListBox1.ListIndex = 0 End Sub Private Sub UserForm_Initialize() Dim i As Byte For i = 1 To 15 ListBox1.AddItem "Ligne" & i Next i End Sub
Vous n’avez pas trouvé la réponse que vous recherchez ?
Posez votre questionWith ListBox1 .MultiSelect = fmMultiSelectSingle .MultiSelect = fmMultiSelectMulti End With ListBox1.ListIndex = 0
Private toto As Integer
Private Sub CommandButton2_Click()
ListBox1.ListIndex = -1
ListBox1.TopIndex = toto
DoEvents
ListBox1.Selected(ListBox1.TopIndex) = True
End Sub
Private Sub ListBox1_Click()
toto = ListBox1.ListIndex
DoEvents
End Sub
ListBox1.ListIndex = -1'désélectionne ListBox1.ListIndex = 0 'selection
Private toto As Integer, titi As Boolean
Private Sub CommandButton2_Click()
ListBox1.ListIndex = -1
ListBox1.TopIndex = toto
DoEvents
ListBox1.Selected(ListBox1.TopIndex) = True
titi = False
End Sub
Private Sub ListBox1_Click()
If titi Then Exit Sub
toto = ListBox1.ListIndex
DoEvents
titi = True
End Sub