Right Click to Select on TreeView

  • Thread starter Thread starter Patrick
  • Start date Start date
P

Patrick

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,
 
* "Patrick said:
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
///
 
Back
Top