Solved

Clearing Tree and Listviews

Posted on 2000-02-23
6
186 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
[Live Webinar] The Cloud Skills Gap

As Cloud technologies come of age, business leaders grapple with the impact it has on their team's skills and the gap associated with the use of a cloud platform.

Join experts from 451 Research and Concerto Cloud Services on July 27th where we will examine fact and fiction.

 

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

PeopleSoft Has Never Been Easier

PeopleSoft Adoption Made Smooth & Simple!

On-The-Job Training Is made Intuitive & Easy With WalkMe's On-Screen Guidance Tool.  Claim Your Free WalkMe Account Now

Question has a verified solution.

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

When designing a form there are several BorderStyles to choose from, all of which can be classified as either 'Fixed' or 'Sizable' and I'd guess that 'Fixed Single' or one of the other fixed types is the most popular choice. I assume it's the most p…
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…
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 Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
Suggested Courses
Course of the Month8 days, 15 hours left to enroll

617 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