|
-
Mar 25th, 2004, 10:13 AM
#1
Thread Starter
Hyperactive Member
mouse event(resolved)
I am working on a vb.net program. I have a treeview control on a form. What I want to do is to pop up a menu when user selects a node by RIGHT MOUSE. How can I do this? thanks.
Last edited by Palmtree; Mar 25th, 2004 at 11:11 AM.
-
Mar 25th, 2004, 10:31 AM
#2
Frenzied Member
Maybe just attach a ContextMenu to your TreeControl?
-
Mar 25th, 2004, 10:39 AM
#3
Thread Starter
Hyperactive Member
thanks for your reply.
Actually my question is more detail, how to use the contextMenu control to create my menu? after that, how to popup it?
-
Mar 25th, 2004, 10:42 AM
#4
Sleep mode
Paste a Context Menu to your form , and paste this code in the Mouse Up event of the treeview .
VB Code:
Private Sub TreeView1_MouseUp(ByVal sender As Object, ByVal e
As System.Windows.Forms.MouseEventArgs) Handles TreeView1.MouseUp
If e.Button = MouseButtons.Right Then
If Not Me.TreeView1.GetNodeAt(New Point(e.X, e.Y)) Is Nothing Then
Me.TreeView1.SelectedNode = Me.TreeView1.GetNodeAt(New Point(e.X, e.Y))
Me.ContextMenu1.Show(Me.TreeView1, New Point(e.X, e.Y))
Else
Me.TreeView1.SelectedNode = Nothing
End If
End If
End Sub
-
Mar 25th, 2004, 10:52 AM
#5
Thread Starter
Hyperactive Member
thanks for the sample code. it helps a lot.
I guess first of all, I need create a popup menu. I drag a contextMenu control on my form, then I want to add "import" and "export" to it, how can do this?
-
Mar 25th, 2004, 10:57 AM
#6
Sleep mode
You just need to fill in the context menuitems as it's main menuitems . Select the context menu control , when it's activated (in design time) ,you'll find it at the top of your form , then you can add items there .
-
Mar 25th, 2004, 10:59 AM
#7
Thread Starter
Hyperactive Member
thanks again. I just figure out how it works. my form is too big and the menu editor was out of my sight. silly me.
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
|