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 treetree.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 nodesStopwatch sw = new Stopwatch();sw.Start();tree.BeginUpdate();tree.ExpandAll(); // Expand ittree.EndUpdate();sw.Stop();MessageBox.Show(sw.Elapsed.TotalMilliseconds.ToString());
Thanks for the help?
Regards
Michael
Hello Michael,
I want to point out that your sample code above is built upon 100k nodes, not 4k. Nonetheless, a performance dip is to be expected with this node count. Do you require all your nodes to be added at once or can they loaded over time as they are made visible? If not you can use Load On Demand:
http://ko.infragistics.com/samples/windows-forms/tree/load-on-demand
Let me know if you'd be interested implementing this or have any additional questions.
Hi Michael,
I'm aware of the big amount of data in my example. It was just to demonstrate what I mean.
But in the meantime I guess I found a solution which bypasses my problem. So thanks for your help.
MIchael
Thank you for following up. If at any point you have time to refactor and share your solution or have any additional questions please do not hesitate to reach out. Have a nice day. Thanks again.