Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations wOOdy-Soft on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Treeview - How do I improve efficiency adding 10000+ nodes

Status
Not open for further replies.

Smiz

Programmer
Oct 25, 1999
1
US
I have an application that creates a TreeView of Data pulled from a DB2 ADO.Recordset<br>
I select over 13,000 records, which can create up to 4 levels.<br>
<br>
I currently do a: Do while Loop for each nextrecord <br>
treeview.nodes.add (Key1, child, Key2, Data1)<br>
<br>
This process takes 5 minutes to load. <br>
Is there a way I can write this to speed up the load time.<br>
Thanks
 
Hi Smiz!<br>
<br>
I can see two answers to your question.<br>
<br>
1) Don't load the sub-trees until the user clicks on the [+] symbol. This is obviously difficult to code, but is the way that Windows Explorer works.<br>
<br>
2) There is an API call named LockWindowUpdate.<br>
<br>
&nbsp;&nbsp;&nbsp;&nbsp;BOOL LockWindowUpdate(<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; HWND hWndLock // handle of window to lock<br>
&nbsp;&nbsp;&nbsp;&nbsp;);<br>
<br>
Call this with the windows handle of your treeview control before loading it up with data. Afterwards call it with a NULL to unlock it. What it does is defer the painting in the window.<br>
<br>
Chip H.<br>

 
I'd go with the first choice. There is no way your users could 13,000 records in one go on screen, why load them? Also, what if they just want to look at the first item? They will have to wait for the other 12,999 item to load first! It is harder to code, but the percieved and actual performance gain is imesurable. If you'de like an example of how to populate a treeview, mail me and I'll get one to you.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top