Results 1 to 2 of 2

Thread: Problem with System.Windows.Forms.TreeView

  1. #1

    Thread Starter
    New Member
    Join Date
    Oct 2002
    Location
    Bergen, Norway
    Posts
    12

    Question Problem with System.Windows.Forms.TreeView

    How can I set the treeview to select nodes on right-click? I would like to have a dropdown menu appear when I right click node. The problem is that the last node is returned as the selected one. I would like to select the rightclicked before the menu appears.

  2. #2
    Addicted Member
    Join Date
    Feb 2002
    Location
    closed
    Posts
    196
    Unless there is a sneaky intrinsic treeview property that can be set that will allow you specify a rightclick select you could trap the mousedown event and force a node selection as in:

    Code:
     Private Sub TreeView1_MouseDown(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles TreeView1.MouseDown
            If e.Button = MouseButtons.Right Then
                Me.TreeView1.SelectedNode = Me.TreeView1.GetNodeAt(New System.Drawing.Point(e.X, e.Y))
            End If
        End Sub
    Last edited by powdir; May 9th, 2003 at 01:38 PM.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width