Solved

Clearing Tree and Listviews

Posted on 2000-02-23
6
183 Views
Last Modified: 2010-05-02
Does anyone know of a FAST way to clear Tree and Listview nodes and list items?

If your tree or List contains a small number of items, it's a simple matter to delete each node, but when the count is high, it takes as long to clear the views as it does to load them.

Since this behavior is true even in Windows explorer (try clicking on a subdirectory with thousands of items), there may not be a workable solution.

The "clear" command is not acceptable, as in a list view it still takes forever to remove the list items. And with a tree, the clear command clears all nodes, not just the selected node.

Thanks.
0
Comment
Question by:carpbyte
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
6 Comments
 
LVL 3

Accepted Solution

by:
TheAnswerMan earned 200 total points
ID: 2551276
Try setting it up as an Array of TreeView.. and Unloading the Control
then ReLoading it.
0
 
LVL 7

Expert Comment

by:Vbmaster
ID: 2551311
I do not think you can get it much faster than it is, using the M$ controls. If the speed is really important you can do like me, create your own usercontrol and using API's like DrawText, DrawIcon, DrawRectangle etc to emulate a listview control. Connect this to a database (not the M$ ones but your own database with simple textfiles or something) and you can too archieve the Clear method as long as it takes to do delete a file from your harddrive. But perhaps there is a way to create database-bound treeview/listviews with the standard M$ controls??
0
 
LVL 15

Expert Comment

by:ameba
ID: 2552616
Tell me if 2.5 x faster than Listitems.Clear is OK?
Also, are you sorting listitems?
0
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

Author Comment

by:carpbyte
ID: 2552992
I need a little more info for the ListView end of things.

For example the following code loads 10,000 items in a listview.

For x=1 to 1000
  Listview1.listitems.add ,,"List" & x
Next x

ListItems.clear takes awhile to clear it.

The same problem would occur if you clicked on another tree node as the listview has to clear all the previous items.


With the treeview you can just delete the topmost node and that takes care of things in the tree, but the listview doesn't have an equivalent heirachy (unless one can be created).

I don't quite follow how to set up an array of the control and removing it.  I get a "Can't unload this object" error.

Sample code would be appreciated.

Thanks.
0
 
LVL 7

Expert Comment

by:Vbmaster
ID: 2554835
You can not unload a control you have created in design-time. You can however create a control in run-time, set its Index property to 0 (zero) and use code like "Load controlname(1)" to instantiate a new control, use that control, and then use "Unload controlname(1)" to unload that new control.
0
 

Author Comment

by:carpbyte
ID: 2556367
AnswerMan's solution works thanks to the additional explanation from VBMaster regarding loading & unloading!

Thanks.

Carpbyte
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

If you have ever used Microsoft Word then you know that it has a good spell checker and it may have occurred to you that the ability to check spelling might be a nice piece of functionality to add to certain applications of yours. Well the code that…
I was working on a PowerPoint add-in the other day and a client asked me "can you implement a feature which processes a chart when it's pasted into a slide from another deck?". It got me wondering how to hook into built-in ribbon events in Office.
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…

736 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question