Tell me more ×
Stack Overflow is a question and answer site for professional and enthusiast programmers. It's 100% free, no registration required.

It's simple to load treeview nodes from table using a recursive function, but it takes a long time for huge data.
I have a table with these fields: id, title, parentid : that keeps treeview nodes in N level.

This table has more than 70000 rows. When i fill treeview from this table it take a long time (about 9 mins) for completion.

Is there a beter solution to increase loading speed?

share|improve this question
Loading e.g. levels>2 only on expanding the parent ... using Treeview.Items.BeginUpdate/Endupdate ... – bummi Apr 17 at 5:40
3  
Use a virtual paradigm: load root nodes only and the rest on demand – pf1957 Apr 17 at 5:42
1  
Yep, virtual control is the solution – David Heffernan Apr 17 at 6:17
@Netlog - Why do you need to load 70000 rows at once? Does not make sense. How many nodes can a user view at one time? 50? 100? Why load them all at once? – Mikey Apr 17 at 7:48
@DavidHeffernan: please back to my question (i did emped my code with TreeView) and let me know how i can do it using VirtualStringTree – Netlog Apr 17 at 7:59
show 2 more comments

2 Answers

You can try TreeView.Items.BeginUpdate/EndUpdate.

But storing 70000 rows in visual control is a questionable idea. Have you considered Virtual TreeView or another way to show only small subset of the data table?

share|improve this answer
i'll try beginupdate/end update and let you know result – Netlog Apr 17 at 6:28
i did test VirtualTreeView or TVirtualStringTree , but it's not useful for this purpose , since it can create milions of nodes only for a node and can't create 70000 nodes in N level – Netlog Apr 17 at 6:30
have you idea to fast load nodes in N level? – Netlog Apr 17 at 6:31
@Netlog I'll tell you the result of you Begin/EndUpdate test now. With 70000 nodes, your performance will never be acceptable until you switch to virtual paradigm. – David Heffernan Apr 17 at 6:31
@Netlog You cannot see thousands of nodes simultaneously, and VT maintains only visible nodes - it increases speed drastically – MBo Apr 17 at 10:41

The standard TTreeView gets slow very quickly as size increases. VirtualTreeview is a perfect solution and can handle millions of nodes without degradation.

share|improve this answer
i did test VirtualTreeView or TVirtualStringTree , but it's not useful for this purpose , since it can create milions of nodes only for a node and can't create 70000 nodes in N level – Netlog Apr 17 at 6:26
have you idea to fast load nodes in N level? – Netlog Apr 17 at 6:32
2  
I'm sure that VTT will do you you want if only you learn how to use it. – David Heffernan Apr 17 at 6:34
@Netlog: that is not true. VTV has no limitations as to where the nodes are created. The RootNodeCount determines the number of top-level nodes. Number of child nodes is determined by calling the InitChildren event. – Smasher Apr 17 at 6:37
Dear Experts; i'm newbie in VirtualStringTree. i did edit my post with Treeview filling ,please let me know how i can do it with VST – Netlog Apr 17 at 7:53
show 2 more comments

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.