Solved

Clearing Tree and Listviews

Posted on 2000-02-23
6
179 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
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
IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

 

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

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

There are many ways to remove duplicate entries in an SQL or Access database. Most make you temporarily insert an ID field, make a temp table and copy data back and forth, and/or are slow. Here is an easy way in VB6 using ADO to remove duplicate row…
You can of course define an array to hold data that is of a particular type like an array of Strings to hold customer names or an array of Doubles to hold customer sales, but what do you do if you want to coordinate that data? This article describes…
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…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…

708 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

Need Help in Real-Time?

Connect with top rated Experts

15 Experts available now in Live!

Get 1:1 Help Now