Posted on January 5, 2009
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
| 'Controls - How to select items in ListBox with right mouse button
Option Explicit
'Add a List Box to your form add few items to the List Box list.
Private Sub List1_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
Dim iTemp As Integer
If Button = vbRightButton Then
With List1
iTemp = ((Y / Screen.TwipsPerPixelY) \ (TextHeight("A") / Screen.TwipsPerPixelY)) _
+ .TopIndex
If iTemp > .ListCount - 1 Then iTemp = -1
.ListIndex = iTemp
.SetFocus
End With
End If
End Sub |