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
1350
ExpandAll performance
posted

Hello,

I need to expand a complete tree. Sometimes we have a lot of nodes with child nodes in that tree, e.g. 4000, and when I then call ExpandAll it takes quit a while.

The following example code demonstrates what I mean. The ExpandAll method needs 3.7sec on my machine. Is there any chance to speed it up? E.g. something like asynchronous ExpandAll ?

// ---- Populate the tree
tree.BeginUpdate();
tree.Nodes.Clear();

for(int i = 0; i < 200; i++) {
    UltraTreeNode rootNode = tree.Nodes.Add(i.ToString(), "Root_" + i.ToString());
    for(int j = 0; j < 10; j++) {
        UltraTreeNode subRootNode = rootNode.Nodes.Add(rootNode.Text + "_" + j.ToString());

        for(int k = 0; k < 5; k++) {
            UltraTreeNode subSubRootNode = subRootNode.Nodes.Add(subRootNode.Text + "_" + k.ToString());

            for(int l = 0; l < 10; l++) {
                UltraTreeNode child = subSubRootNode.Nodes.Add();
                child.Text = "Element " + l.ToString();
            }

        }

    }

}

tree.EndUpdate();

// ---- Expand all nodes
Stopwatch sw = new Stopwatch();
sw.Start();
tree.BeginUpdate();
tree.ExpandAll(); // Expand it
tree.EndUpdate();
sw.Stop();
MessageBox.Show(sw.Elapsed.TotalMilliseconds.ToString());

Thanks for the help?

Regards

Michael