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
460
Getting "The ActiveNode can only be set to a node that belongs to this control." error when node is part of the control
posted

I have version 2009.2  and I am running into the same problem.  I can loop through all of the nodes and their child nodes and find the node that I am trying to activate but it gives me the error.  Here is my code 

It reaches the if (parentNode.Nodes.Contains(_clickedNode)) and it returns true but as soon as I hit the line ActiveNode = parentNode.Nodes[_clickedNode.Index]; it errors out with "The ActiveNode can only be set to a node that belongs to this control."

 

   private void SetNodeAsActive(UltraTreeNode parentNode, UltraTreeNode clickedNode)

        {

            if (parentNode.Nodes.Contains(_clickedNode))

            {

                this.SelectedNode.Nodes.Clear();

                parentNode.Nodes[_clickedNode.Index].Selected = true;

 

                ActiveNode = parentNode.Nodes[_clickedNode.Index];

            }

            else

            {

                foreach (var parentNodes in parentNode.Nodes)

                {

                    SetNodeAsActive(parentNodes, clickedNode);

                }

            }

        }

 

I have also tried and I get the error as well

 

        private void SetNodeAsActive(UltraTreeNode parentNode, UltraTreeNode clickedNode)

        {

            if (parentNode.Nodes.Contains(_clickedNode))

            {

                this.SelectedNode.Nodes.Clear();

                _clickedNode.Selected = true;

 

                ActiveNode = _clickedNode;

            }

            else

            {

                foreach (var parentNodes in parentNode.Nodes)

                {

                    SetNodeAsActive(parentNodes, clickedNode);

                }

            }

        }