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.
Join the conversation! Your thoughts help the community grow.
Sign in to leave a comment
It is the same account you read, post and publish with — and you will come straight back to this page.

Mike GoldPosted Aug 7, 2008, 10:59 AM
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, 3:57 PM
Is this when adding nodes dynamically at runtime or over a period of time as you slowly add more nodes to the treeview?