c# slow treeview

  • Thread starter Thread starter orenwantsyou
  • Start date Start date
O

orenwantsyou

hi all,
i have a c# winform application and a web appliaction.
in the winform app. i use a treeview control, and in the web app. i use
an htc control.
the problem is that the winform application is loading very slow(the
tree), whereas the web application's tree is loading quicker.
both applications usews the same functions when it creates the tree,
anyone knows why????
 
If you can post the code you're using to populate the treeview, that
might help in identifying any problems!

Thanks!
 
it's a bit of a problem, since that there many functions that are being
called in the way.
i digged the code, and i think that it's not the treeview fault, but
i'm not sure.
i removed the part when the treevies/htc is rendered , and the problem
still occured.
i
 
it's a bit of a problem, since that there many functions that are being
called in the way.
i digged the code, and i think that it's not the treeview fault, but
i'm not sure.
i removed the part when the treevies/htc is rendered , and the problem
still occured.
 
Okay...one thing you want to keep in mind is that you should call the
treeview's BeginUpdate and EndUpdate methods at the point(s) where you
load the data into the treeview. This isn't such a big deal (I don't
think) when you're using the AddRange() method but if you're adding the
tree's items individually, then you'll definitely want to use these
methods to disable repainting of the treeview prior to the update and
then re-enable painting of the treeview after the update.

So you'll have something like...

/******************************************/
myTreeView.BeginUpdate();
// create and populate the tree view based on individual
// items in a collection...
foreach(BeerCan obj in Fridge)
{
myTreeView.Nodes.Add(new TreeNode("Beer Name: " + obj.Name));
}
myTreeView.EndUpdate();
/******************************************/

Other than that, you may just want to make sure that your other code is
optimized (which you already said you want to check on).
Good luck!
 
Back
Top