Celebrate National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Clearing TreeViews

Posted on 1998-10-21
10
Medium Priority
?
251 Views
Last Modified: 2010-05-18
Hi all.

Is there a quicker way of clearing a treeview than using TTreeView.Items.Clear???  I have 870 items in the view and it takes for ever to clear (on a P266).  Im using it to display search results.

Cheers!

Stu.
0
Comment
Question by:Stuart_Johnson
[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
10 Comments
 
LVL 12

Accepted Solution

by:
rwilson032697 earned 200 total points
ID: 1343817
Use LockWindowUpdate to stop the treeview redrawing while its clearing.
0
 
LVL 6

Author Comment

by:Stuart_Johnson
ID: 1343818
Just a quick question... Is this how I do it?

LockWindowUpdate(ListView1.Handle);
ListView1.Items.Clear;
LockWindowUpdate(0);

Do I need to specify the last line?  

Stuart.
0
 
LVL 10

Expert Comment

by:viktornet
ID: 1343819
Yes you need to otherwise it won't be unlocked.... The code above is right...

Cheers,
Viktor
0
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 
LVL 6

Author Comment

by:Stuart_Johnson
ID: 1343820
Thanks guys!  Much appreciated
0
 
LVL 6

Author Comment

by:Stuart_Johnson
ID: 1343821
Hi Guys, me again :)

I just tried at out on the application here (I asked the question at work and the program is at home) and it is still too slow.  Its taking around 5-10 seconds to clear the TreeView.

It really has to be quicker than that.  I am hoping for a refresh time of less than a second.

Is there an API I can use to clear it?  Or is my only hope disposing of the TreeView and creating another one?

Thanks for the info if you can provide it.

Stuart.
0
 
LVL 12

Expert Comment

by:rwilson032697
ID: 1343822
You could try destroying it and creating another one as you suggest.

Another (sneaky) way might be to have 2 or more treeviews. You fill one up, then user does another search so you swap the full one to the back and fill up the one on top. In the OnIdle event you could kill a few of the elements at a time to eventually empty it and make it available again.

This is fairly much overkill though. Just killing the control should be tons easier!
0
 
LVL 6

Author Comment

by:Stuart_Johnson
ID: 1343823
Mmm..  I dont really like the idea of doing that.  There is too much code attached to it to just delete it.   That was a last resort solution.

Surely there is a way of clearing it quickly. M$ does it with the Explorer.

Stu.
0
 
LVL 12

Expert Comment

by:rwilson032697
ID: 1343824
I think part of the reason it can be slow is that Delphi is having to kill large numbers of huge strings. There are some TTreeView derived classes on DSP - one of those might have a fast clear method.

http://sunsite.icm.edu.pl/delphi
0
 

Expert Comment

by:5214305
ID: 1343825
Tree.Items.BeginUpdate;
Tree.Items.Clear;
Tree.Items.EndUpdate;

That's pretty fast and doesn't require any API call.
0
 
LVL 6

Author Comment

by:Stuart_Johnson
ID: 1343826
5214305

Your "comment" actually worked the best.  The list is clear quicker than the blink of an eye.  Could you email me at jonstu@acay.com.au and I'll set up a dummy question for you.  You definately deserve some points for that one!

Stu.
0

Featured Post

On Demand Webinar: Networking for the Cloud Era

Did you know SD-WANs can improve network connectivity? Check out this webinar to learn how an SD-WAN simplified, one-click tool can help you migrate and manage data in the cloud.

Question has a verified solution.

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

This article explains how to create forms/units independent of other forms/units object names in a delphi project. Have you ever created a form for user input in a Delphi project and then had the need to have that same form in a other Delphi proj…
Introduction The parallel port is a very commonly known port, it was widely used to connect a printer to the PC, if you look at the back of your computer, for those who don't have newer computers, there will be a port with 25 pins and a small print…
Add bar graphs to Access queries using Unicode block characters. Graphs appear on every record in the color you want. Give life to numbers. Hopes this gives you ideas on visualizing your data in new ways ~ Create a calculated field in a query: …
In this video, Percona Solutions Engineer Barrett Chambers discusses some of the basic syntax differences between MySQL and MongoDB. To learn more check out our webinar on MongoDB administration for MySQL DBA: https://www.percona.com/resources/we…
Suggested Courses

730 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