|
-
Aug 11th, 2005, 05:56 AM
#1
Thread Starter
Member
Right-clicking on a ListView component
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
-
Aug 11th, 2005, 06:00 AM
#2
Re: Right-clicking on a ListView component
 Originally Posted by Dr.Rock
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.
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
-
Aug 11th, 2005, 09:26 AM
#3
Thread Starter
Member
Re: Right-clicking on a ListView component
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.
Last edited by Dr.Rock; Aug 11th, 2005 at 09:34 AM.
-
Aug 11th, 2005, 12:22 PM
#4
Re: Right-clicking on a ListView component
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
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|