Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
20
Ultra Tree view Node Right click Event
posted

Hi,

Can anybody tell me what is the equivalent event of

"NodeMouseClick" in Ultra Tree View for getting the Context menu strip.

 

M.

Parents
  • 119
    posted

    mansi,

    You can use the contextmenu property of the tree itself if all you want to do is show a context menu for a right click on a node.  If you are using columns in the tree (e.g., OutlookExpress style), you can set up a context menu for the editor control assigned to the column.

    As far as working with a nodemouseclick, in a Tree_MouseDown event handler you can use a hittest as in this code:

    Private Sub MyTree_MouseDown(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles MyTree.MouseDown

         Dim hittestnode As UltraTreeNode = Me.MyTree.GetNodeFromPoint(Me.MyTree.PointToClient(Me.MousePosition))
        
    If hittestnode Is Nothing Then Exit Sub

         ' Check for right click to get contextmenu
        
    If e.Button = MouseButtons.Right Then Exit Sub

         ' Get reference to cell under mouse position
        
    Dim cell As UltraTreeNodeCell = CellFromPoint(Me.MyTree, Me.MousePosition)
        
    If cell Is Nothing Then Exit Sub

         Etc.

    Hope this helps,

    JC

Reply Children