Execute a Menu when List is right clicked
Okay, I have a listview, all filled out etc. I am trying to add a few nice options on to it, and I thought the best way to organize it would be in a Menu. Except, I have a problem:
How would I pop up the menu when a row was right clicked on the listview?
Re: Execute a Menu when List is right clicked
VB Code:
Private Sub ServerB_MouseDown(Button As Integer, Shift As Integer, x As Single, y As Single)
If Button = vbRightButton Then
PopupMenu PopMenu 'must be valid top level menu item
End If
End Sub
Re: Execute a Menu when List is right clicked
This will popup a menu, and select the item you right mouse clicked on.
VB Code:
Private Sub ListView1_MouseDown(Button As Integer, Shift As Integer, x As Single, y As Single)
Dim lvwItem As ListItem
If Button = vbRightButton Then
Set lvwItem = ListView1.HitTest(x, y)
If Not lvwItem Is Nothing Then
lvwItem.Selected = True
PopUpMenu mnuFile
End If
End If
End Sub