Private Sub ListeProduits_MouseMove(ByVal Button As Integer, ByVal Shift As Integer, ByVal X As Single, ByVal Y As Single)
Dim i As Byte
Dim j As Byte
With ListeProduits
If .MultiSelect > 0 Then ' si on a la multiselection
For i = 0 To .ListCount - 1 ' on compte le nombre de sélection
If .Selected(i) = True Then j = j + 1
Next i
' si tout est sélectionné
If j = .ListCount Or j = .ListCount - 1 Then
'alors on affiche un message
Call MsgBox("Vous devez cocher ""Tous""" _
& vbCrLf & "" _
, vbInformation, Application.Name)
' et on supprime les sélections
For i = 0 To .ListCount - 1
.Selected(i) = False
Next i
Exit Sub
End If
' si "tous" est sélectionné en dernière position
If .Selected(.ListCount - 1) = True Then
' on supprime la multisélection et se positionne sur tous
.MultiSelect = 0
.ListStyle = 0
.ListIndex = .ListCount - 1
End If
Else
' si pas de multisélection
If .ListIndex = .ListCount - 1 Then Exit Sub
' si pas de multisélection et si on change le produit sélectionné
' on rétablit la multisélection
j = .ListIndex
.MultiSelect = fmMultiSelectMulti
.ListStyle = fmListStyleOption
' on coche le produit
.Selected(j) = True
End If
End With
End Sub