tree-view item and context menu

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Darin

    tree-view item and context menu

    I have a form w/ a treeview on it, and a context menu tied to the
    tree-view. I need to know what field on the tree is in blue when the
    user does the right click. I thought I could use the treenode.text, but
    that always returns the first option on the tree and the option that is
    in blue. But, if i do the double-click, the text is the option that is
    blue.

    How can i get the highlighted option that wasn't double-clicked, but
    instead was only right-clicked on?

    Darin

    *** Sent via Developersdex http://www.developersdex.com ***
  • Tom Shelton

    #2
    Re: tree-view item and context menu

    On 2008-06-23, Darin <darin_nospam@n ospameverwrote:
    I have a form w/ a treeview on it, and a context menu tied to the
    tree-view. I need to know what field on the tree is in blue when the
    user does the right click. I thought I could use the treenode.text, but
    that always returns the first option on the tree and the option that is
    in blue. But, if i do the double-click, the text is the option that is
    blue.
    >
    How can i get the highlighted option that wasn't double-clicked, but
    instead was only right-clicked on?
    >
    Darin
    >
    *** Sent via Developersdex http://www.developersdex.com ***
    If I understand what your asking then you probably want to handle the context
    menus Opening event. I usually do something like:

    Sub theContextMenu_ Opening (ByVal sender As Object, ByVal e As CancelEventArgs ) Handles theContextMenu. Opening
    Dim hti As TreeViewHitTest Info = theTreeView.Hit Test (Me.PointToClie nt (Curosr.Positio n))
    If hti.Node Is Nothing Then
    e.Cancel = True
    Else
    ' do stuff with the node
    End If
    End Sub

    HTH
    --
    Tom Shelton

    Comment

    • Darin

      #3
      Re: tree-view item and context menu

      This is closer, but the cursor position is not always the selected node,
      but sometimes nodes 4 or 5 positions away.

      Darin

      *** Sent via Developersdex http://www.developersdex.com ***

      Comment

      Working...