Articles in this section

How to select a node in the WinForms TreeViewAdv control with a right click?

Select a node in TreeViewAdv with right click

Listen to the MouseDown event of the TreeViewAdv control and set the SelectedNode property to the node on which you right clicked as demonstrated by the following code sample:

C#

private void treeViewAdv1_MouseDown(object sender, System.Windows.Forms.MouseEventArgs e)
{
   if(e.Button == MouseButtons.Right)
   {
      this.treeViewAdv1.SelectedNode = this.treeViewAdv1.GetNodeAtPoint(new Point (e.X,e.Y));
   }
}

VB

Private Sub treeViewAdv1_MouseDown(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs)
   if e.Button = MouseButtons.Right Then
      Me.treeViewAdv1.SelectedNode = Me.treeViewAdv1.GetNodeAtPoint(New Point (e.X,e.Y))
   End If
End Sub

Did you find this information helpful?
Yes
No
Help us improve this page
Please provide feedback or comments
Comments (0)
Access denied
Access denied