By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
443,524 Members | 1,593 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 443,524 IT Pros & Developers. It's quick & easy.

Right Click to Select on TreeView

P: n/a
This may be a simple question but how can I make the tree change the
selected node... on a right click .. in addition to the left click?

What I want is to filter my context menu based on the type of node selected
but the left click doesn't seem to change the selected node.

Thanks,

Nov 20 '05 #1
Share this Question
Share on Google+
1 Reply


P: n/a
* "Patrick" <py**@oneshield.com> scripsit:
This may be a simple question but how can I make the tree change the
selected node... on a right click .. in addition to the left click?


\\\
Private Sub TreeView1_MouseUp( _
ByVal sender As Object, _
ByVal e As System.Windows.Forms.MouseEventArgs _
) Handles TreeView1.MouseUp
If e.Button = MouseButtons.Right Then
Dim n As TreeNode = Me.TreeView1.GetNodeAt(e.X, e.Y)
If Not n Is Nothing Then
Me.TreeView1.SelectedNode = n
Me.MenuItem1.Text = n.Text
Else
Me.MenuItem1.Text = "(no item selected)"
End If
Me.ContextMenu1.Show(Me.TreeView1, New Point(e.X, e.Y))
End If
End Sub
///

--
Herfried K. Wagner [MVP]
<URL:http://dotnet.mvps.org/>
Nov 20 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.