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 bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

TreeView, add more than 32767 nodes to the tree?

Status
Not open for further replies.

metricspaces

Programmer
Nov 7, 2008
1
IE
Hi,

I'm using VB6 and the TreeView from "Microsoft Windows Common Controls.". Due to the bug it is not possible to add more than 32767 nodes to the tree.

I want to add 100,000's items to the TreeView.

Is there any work around for this problem?

Is there any other implementation of TreeView that I can use with VB6 and does not suffer from this problem?

I have found a reference to Virtual Tree from but this only works with .NET.

Any help greatly appreciated,

Thanks,

Máirtín
 
You need to be aware that, whilst the KB article you link to implies that this is a VB bug, the actual 'bug' is in the TreeView control itself, and the behaviour described is actually documented as such in the TreeView control documentation (and since it is documented behaviour it isn't technically a bug ...).

Additionally, even without the 'bug', the limit for the Windows TreeView control is 65537 nodes beccasue of Integer rollover (again, as described in the article).

Also, performance of the control gets very sluggish with several thousand nodes. Hundreds of thousands, even if the use of integers in the control didn't prohibit it, would force it to a standstill.

So you are right, you need a 3rd party control that looks like TreeView. Trouble is that most of the 3rd party controls of which I have been aware (e.g. Sheridan Active Treeview control, sstree) were just better/more advanced wrappers around the underlying Windows control than the VB5/6 wrapper - so they'd all suffer the same limitation. Or, of course, you might just want to have a long hard think about whether hundreds of thousands of nodes in once control is the best approach ...
 
metricspaces said:
I want to add 100,000's items to the TreeView.
I can't imagine that as being practical. What if the thing I'm looking for is on the 99,999th node? What will happen is either:

1. If the hierarchy does not go too deep, you will be scrolling downwards and probably die of old age before you get far enough
OR
2. You will have so many parent nodes that by the time you find what you are looking for, you will have several screen widths of expanded nodes open on the left side

Do the decent thing for your users and build them a search screen instead.

However, for purely academic reasons I will give you a way you could do this (or actually the illusion of doing this). Simply, you do not need to load all 100,000 nodes at once. All you really need is to load all the nodes that have the Root node as their parent, and one child node of each of these. The rest of the nodes can be added dynamically as needed (i.e. when the user expands a parent node).

Joe Schwarz
Custom Software Developer
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top