Adding nodes to a treeview control gets progressively slower
Posted on 2008-06-25
Hi, first time asking a question here - so be gentle with me! I've been searching solutions for this problem, but couldn't really find anything that fit.
I have a vb6 project wich is fairly complex. In it I have a treeview, which lists quite a few items (the subnodes are not added before they are viewed). The treeview takes quite long to build, and it seems it gets progressively slower with a larger amount of nodes.
An itemset with 3570 nodes takes 41,5 seconds, 4369 takes 52,7 seconds - and a set combining both takes 119 seconds (just adding the time it takes for set 1 and 2 gives around 94 seconds). Should I expect it to be like this?
The nodes are added in a while loop going through the dataset, adding them like this:
TreeView1.Nodes.Add(, , key, label)
Before the loop, the tree is set to not visible:
TreeView1.Visible = False
to help on the time it takes to set it up. It helps (examples shown are with the tree already set to not visible during building it).
Any ideas what I can do/look at to get this thing to go faster?