how to select treeview nodes using right click

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • chandu5090
    New Member
    • May 2007
    • 5

    how to select treeview nodes using right click

    Hi
    i have some nodes in the treeview. how can i select the node by directly right clicking on the node?
  • chandu5090
    New Member
    • May 2007
    • 5

    #2
    Finally I got the answer...
    Private Sub TreeView1_Mouse Up(ByVal sender As Object, ByVal e As System.Windows. Forms.MouseEven tArgs) Handles TreeView1.Mouse Up
    ' Show menu only if Right Mouse button is clicked
    If e.Button = Windows.Forms.M ouseButtons.Rig ht Then
    ' Point where mouse is clicked
    Dim p As Point = New Point(e.X, e.Y)
    ' Go to the node that the user clicked
    Dim node As TreeNode = TreeView1.GetNo deAt(p)
    If Not node Is Nothing Then
    TreeView1.Selec tedNode = node
    ' ContextMenuStri p1.Show(TreeVie w1, New Point(e.X, e.Y))
    End If
    End If
    End Sub

    Comment

    Working...