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
144
How to highlight Node on mouse Rightclick (UltraTree)
posted
I have to popup a context menu on Right click of the mouse. The behavior should be similar to windows folder Right click selection. The problem I am facing is that the node is not being highlighted when I right click on the node.
Parents
No Data
Reply
  • 69832
    Offline posted

    You can handle MouseDown, use GetNodeFromPoint to get the node at the cursor location (remember to check for null first), and set the node's Selected property to true.

    Example:
    private void ultraTree1_MouseDown(object sender, MouseEventArgs e)
    {
        if ( e.Button == MouseButtons.Right )
        {
            UltraTree treeControl = sender as UltraTree;
            UltraTreeNode nodeAtPoint = treeControl.GetNodeFromPoint( e.Location );

            if ( nodeAtPoint != null )
            {
                nodeAtPoint.Selected = true;
            }
        }
    }

Children