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
80
UltraTree - error while set the first node of tree be invisible
posted

my application requires refreshing nodes in ultra tree. I want to remove or hide some nodes with specific attributes. One of the deleted nodes is the first node added to the tree.

If I set that node visible = false I get the following error:

"The ActiveNode can only be set to a node that belongs to this control."

If I try to remove that node, I get error:

"Index was out of range. Must be non-negative and less than the size of the collection.
Parameter name: index"

Here is my code:

- Create a new UltraTree with name ultraTree1

 void createTree()
        {
            //the following code causes problem
            ultraTree1.BeginUpdate();

            ultraTree1.Nodes.Clear();
            ultraTree1.Focus();

            UltraTreeNode _n1 = ultraTree1.Nodes.Add("node 1");

            UltraTreeNode _n2 = ultraTree1.Nodes.Add("node 2");

            ultraTree1.ActiveNode = null;
           
            //_n1.Visible = false;
            _n1.Remove();
           
            //the code causing problem
            ultraTree1.EndUpdate();
        }

and the main class:

 public Form1()
        {
            InitializeComponent();

            createTree();//works ok
        
            createTree(); //get error
        }

 

I found out that BeginUpdate() and EndUpdate() cause these errors. It works ok if I comment out BeginUpdate() and EndUpdate(). However, I want to use these methods because my tree has considerable large number of nodes.

Do you have any hot fix for that issue ???

I use Infragistics 9.1

 

 

Parents
  • 69832
    Verified Answer
    Offline posted

    There was a recent fix that was applied to 2008.3 and later that might have addressed this;

    you should download the latest version and see if it solves the problem.

    If it doesn't, report it as a bug and in the meantime, try moving the call to the Remove method outside the BeginUpdate/EndUpdate block.

  • 460
    posted in reply to Eric

    I have opened a new post on this issue go here http://forums.infragistics.com/forums/p/41506/230477.aspx#230477

     

    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);

                    }

                }

            }

     

     

Reply Children