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
105
Determine if node checkbox was clicked on MouseClick
posted

Hi,

 I have an UltraTree that uses the MouseClick event to determine if a node is clicked.  At this point if a node was clicked, I expand/collapse the node.  I now want to allow for checkboxes, as well as this feature.  The MouseClick fires before the BeforeCheck and AfterCheck events.  Because of this, I do not know how to determine if the checkbox was clicked, and therefore the node is expanded/collapsed when the checkbox is checked.  Is there anyway during the MouseClick event, that I can determine if the checkbox was clicked or the text of the node was clicked?  I don't want the node expanded/collapsed when the node checkbox is clicked, only the text.

 Thank you,

Jake

  • 469350
    Verified Answer
    Offline posted

    Hi Jake,

        How are you getting the node to expand/collapse? I assume you must be using UIElements. This is the same way you would determine if the click was on a checkbox.  

            private void ultraTree1_MouseClick(object sender, MouseEventArgs e)
            {
                UIElement element = this.ultraTree1.UIElement.LastElementEntered;
                if (element == null)
                    return;

                // If the element is a checkbox, return.
                if (element is CheckIndicatorUIElement)
                    return;

                // If the element is the child of a checkbox, return.
                if (element.GetAncestor(typeof(CheckIndicatorUIElement)) != null)
                    return;

                // Get the node from the element (could be null).
                UltraTreeNode node = element.GetContext(typeof(UltraTreeNode)) as UltraTreeNode;                       
            }