The ListBox fires its Click event when the user clicks on an item or when the program sets its value as in:
lstAnimals.ListIndex = 1
To tell which is the case, create a module-level Boolean variable m_MouseClicking.
In the ListBox's MouseDown event handler, set this value to True. Check the value in the Click
event handler. In the ListBox's MouseUp event handler, set this value back to False.
|
Private m_MouseClicking As Boolean
Private Sub lstAnimals_MouseDown(Button As Integer, Shift _
As Integer, X As Single, Y As Single)
m_MouseClicking = True
End Sub
Private Sub lstAnimals_MouseUp(Button As Integer, Shift As _
Integer, X As Single, Y As Single)
m_MouseClicking = False
End Sub
Private Sub lstAnimals_Click()
If m_MouseClicking Then
lblSource.Caption = "Mouse Click"
Else
lblSource.Caption = "Code"
End If
End Sub
|