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
120
Select node performance
posted

 Hi,

I have tree with thousands of nodes (up to 2 000). Loading is quite fast thanks to AddRange method in Nodes property. Now I have a task to set many of the nodes (or each of them) to Selected = true. There is very bad performance with that.

Code looks like that:

foreach( UltraTreeNode childNode in Nodes)

{

 if( someCondition)

{

  childNode.Selected = true;

}

}

 

Profiler says, that most of the time is spent in node.Selected = true (more specifically SelectedNodesCollection.InternalAdd and finaly ArrayList.Contains - this is the problem). I was trying to find something like SelectedNodes.AddRange method or something like that but with no success. What can I do to speed up nodes selection ? Thanks for any advice.

Daniel

Parents
  • 469350
    Offline posted

    Hi Daniel,

    The performance problem is most likely caused by the contanst painting of the control. Try this: 

     

    tree.BeginUpdate();

    try

    {

    foreach( UltraTreeNode childNode in Nodes)

    {

     if( someCondition)

    {

      childNode.Selected = true;

    }

    }

    }

    finally

    {

    tree.EndUpdate();

    }

     

Reply Children