I have created a ListView box that displays some text-based items.
How would I do it so when someone right-clicks on an item, it manefests a pop-up menu with options?
Thanks
Printable View
I have created a ListView box that displays some text-based items.
How would I do it so when someone right-clicks on an item, it manefests a pop-up menu with options?
Thanks
Create a menu using the standard Menu Editor.Quote:
Originally Posted by Dr.Rock
Set the top level menu's visible property to False.
For the sake of an example, I will use mnuFile as the top level menu.VB Code:
Private Sub ListView1_MouseDown(Button As Integer, Shift As Integer, x As Single, y As Single) If Button = vbRightButton Then PopUpMenu mnuFile End If End Sub
Thanks for that. It works so far with my app.
But the menu item I right-click on does not highlight. Is there a way that the menu item highlights when I right-click, before the pop-up menu comes? The popup menu is to refer to the item I select via right-click.
Thanks.
Use the HitTest method to determine which Item the mouse is clicked upon.
Note that the View and FullRowSelect property values affect how the HitTest method determines if an Item is at the X, Y coordinate.
VB Code:
Private Sub ListView1_MouseDown(Button As Integer, Shift As Integer, x As Single, y As Single) Dim oItem As ListItem If Button = vbRightButton Then Set oItem = ListView1.HitTest(x, y) If Not oItem Is Nothing Then oItem.Selected = True popupmenu mnuFile End If End If End Sub