Click here to Skip to main content
15,891,316 members
Please Sign up or sign in to vote.
5.00/5 (2 votes)
See more:
C#
for(int i =0;i<400;i++)
{
     treeNodes[i].Text = name;
     treeNodes[i].group[i].BackColor = Color.LightBlue;
}


This loop can take my computer up to 2 minutes. But removing the label rename removes all the lag.

C#
for(int i =0;i&lt;400;i++)
{
     //treeNodes[i].Text = name;
     treeNodes[i].group[i].BackColor = Color.LightBlue;
}


Any clue why 400 label renames should bog the system down and how do I fix it?

________________

It is a winform so all I needed to do was
treeView1.BeginUpdate();
//tree editing stuff
treeView1.EndUpdate();

This removed all lag. Thanks!
Posted
Updated 20-Feb-10 5:21am
v3

1 solution

Is this WinForms?

Have you tried wrapping your code in BeginUpdate and EndUpdate calls?

Nick
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900