c# slow treeview

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????
 
G

GreggTB

If you can post the code you're using to populate the treeview, that
might help in identifying any problems!

Thanks!
 
O

orenwantsyou

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
 
O

orenwantsyou

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.
 
G

GreggTB

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!
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top