G
Guest
Hello, All,
I have a Windows Forms TreeView with about 1500 nodes. It takes only a
second to initially populate and display the TreeView with those 1500 nodes,
but if I want to mass update the Text property of all the nodes, it takes
almost 50 seconds!
The following code changes the Text property recursively, but I also
flattened the code into a while loop and it still took 50 seconds. I've
wrapped the method with a SuspendLayout / ResumeLayout. I've wrapped the
method by hiding the TreeView then displaying it when it's done. Still 50
seconds.
Does anyone have any idea why it takes so long to update the Text property
of 1500 TreeNodes? Thank you.
void UpdateTreeNodeTextRecursive( TreeNodeCollection nodes )
{
foreach (TreeNode loNode in nodes)
{
if (loNode.Nodes.Count > 0)
{
UpdateTreeNodeTextRecursive( loNode.Nodes );
}
loNode.Text = "Hello World!";
}
}
I have a Windows Forms TreeView with about 1500 nodes. It takes only a
second to initially populate and display the TreeView with those 1500 nodes,
but if I want to mass update the Text property of all the nodes, it takes
almost 50 seconds!
The following code changes the Text property recursively, but I also
flattened the code into a while loop and it still took 50 seconds. I've
wrapped the method with a SuspendLayout / ResumeLayout. I've wrapped the
method by hiding the TreeView then displaying it when it's done. Still 50
seconds.
Does anyone have any idea why it takes so long to update the Text property
of 1500 TreeNodes? Thank you.
void UpdateTreeNodeTextRecursive( TreeNodeCollection nodes )
{
foreach (TreeNode loNode in nodes)
{
if (loNode.Nodes.Count > 0)
{
UpdateTreeNodeTextRecursive( loNode.Nodes );
}
loNode.Text = "Hello World!";
}
}