Every time you add a node to a treeview, it slows down the program. That is because after each node, the treeview repaints. This can get expensive for a good deal of nodes. Luckily the treeview has built in methods BeginUpdate and EndUpdate to solve the problem. Calling BeginUpdate before you add nodes and EndUpdate after you have finished greatly speeds up the addition of nodes to your treeview.
How To: Speeding up adding nodes to a Treeview
Not sure if others have experienced this, but if you try to add a lot of nodes to a treeview, the program will progessively slow down with the addition of each node. Here is how to solve the problem.


Mike GoldTOP 100Posted Aug 7, 2008, 6:59 AM EDT
That is when adding nodes dynamically at runtime all at once. Because if you don't use BeginUpdate, EndUpdate, it will trigger a paint message for every node added. So imagine looping over a few hundred nodes and adding them, dynamically without disabling the paint message. This would cause Windows to try to paint every node each time through the loop. If you slowly add nodes every so often, you probably don't need to be concerned about using BeginUpdate/EndUpdate, because this is only one paint message which has time to be processed in the windows message queue.
StephenPosted Aug 6, 2008, 11:57 AM EDT
Is this when adding nodes dynamically at runtime or over a period of time as you slowly add more nodes to the treeview?