I'm using the TreeView control to display a list of airports worldwide. The fields include:
Country, State/Prov, City, Airport
The source is a simple text file. The total number of Airports locations is 23,821. The Tree loads up and displays all the airports correctly. The problem occurs when you end the program. If you close it while in VB6 it freezes VB6 for close to two minutes. (You can run other apps during this time, only VB6 is frozen). If you compile the program and run it outside of VB the same problem occurs. When you end the program it clears the screen immedialtey but if you pull up the task list the program still shows as loaded and running. After a short delay the program then shows as still loaded but "not responding". It does eventually close. (On closing I "unload" the form and then "End" the program).
If I limit the number of Airports displayed the "Hang" time is reduced accordingly. Could this be related to some kind of memory problem? Does the TreeView have a maximum number of branches? Never had this problem before. Any ideas?
There's nothing wrong with the code you show. I'm a little concerned about the Close: label and I hope you are not doing a GoTo Closesomeplace in the Sub. If you aren't then it doesn't hurt anything but you don't need the label.
I think I remember someone else having a problem closing a form that had a large treeview. It will probably be hard to find but you might use the Advanced Search and look for something like treeview close and see what you can find.
I'm not sure what's causing your issue, but one thing to consider is dynamically populating the childen nodes when the parent node is expanded - i.e., load only the countries first - then when a country is expanded, load the corresponding states - when the state is expanded, load the cities - and so on. (you could even remove the children nodes when the parent is collapsed)
This of course requires a bit more coding on your part, but it will keep the node count to a minimum ...