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
925
Expand/collapse node on single mouse click
posted

How can I make an ultra tree node expand on a single mouse click? I know there's a double mouse click action to toggle the expansion, but I can't see the same for a single mouse click. I've tried using the mouse click event and getting the node under the mouse; this worked apart from the event was also fired when you click on the expansion indicator. I want to keep the expansion indicator so I guess I either need a way to disable the built in expansionIndicator.click, or figure out whether the user clicked on the actual node or the expansion indicator.

Parents
  • 69832
    Offline posted

    private void ultraTree1_MouseDown(object sender, MouseEventArgs e)
    {
        UltraTree treeControl = sender as UltraTree;
        UltraTreeUIElement controlElement = treeControl.UIElement;
        UIElement elementAtPoint = controlElement != null ? controlElement.ElementFromPoint( e.Location ) : null;

        bool isOverExpansionIndicator = false;
        UltraTreeNode nodeAtPoint = elementAtPoint != null ?
            elementAtPoint.GetContext( typeof(UltraTreeNode) ) as UltraTreeNode :
            null;

        if ( nodeAtPoint != null )
        {
            while ( elementAtPoint != null )
            {
                if ( elementAtPoint is Infragistics.Win.UltraWinTree.ExpansionIndicatorUIElement )
                {
                    isOverExpansionIndicator = true;
                    break;
                }

                elementAtPoint = elementAtPoint.Parent;
            }

            if ( isOverExpansionIndicator == false )
                nodeAtPoint.Expanded = ! nodeAtPoint.Expanded;
        }
    }

Reply Children
No Data