Question
I found the tree control is too slow when I have loaded a large number of entries (1000 - 2000). It can take half a minute to end a drawing when the tree has such a large number of entries, why?
Answer
There is good way to solve this. What is happening is that you are loading a large amount of data into the tree control. Any tree control will have a difficult time handling a large amount of data. The solution is to load only that which needs to be displayed. So for example if you have a single main parent item, add it to the tree control, then add one child item, titled something specific and intentional like "Erase Me" or "Not Loaded Yet". This way the parent tree item appears to the user to have children. Then from the OnItemExpanding event check to see if there is one child item and if it is titled "Erase Me" or "Not Loaded Yet". If so, then delete that child item and then add all the correct child data item(s) to that parent. What this does is it sets up the tree control for demand loading. This way only what is displayed to the user is loaded into the tree control and it saves a tremendous amount of memory. Closing will then be very quick.
We have done this before with tree controls that display entries from a large database. When the program loaded 100% of the data it took minutes. Once we setup the tree control for demand loading like this, the load and display time was instant.
Knowledge Base
FAQ