Board index » cppbuilder » TListView->Items->Clear() is deadly slow

TListView->Items->Clear() is deadly slow

Hi!

I'm using ListView component in CBB 5 and when I try to clear it using
either Items-.Clear() or Items->Delete() (in a loop) methods, it functions
DEADLY slow. Clearing of ListView containing about 60 items takes about a
second on my P-II-400 128M but I need, may be, a thousand items in the
list... I noted this time vary depending on size of ListView - more size -
more time it takes. Adding items into list is fast.

What can I do to avoid this problem?

Sergey Shapovalov.

 

Re:TListView->Items->Clear() is deadly slow


On Fri, 20 Jul 2001 18:38:30 +0300, "Sergey Shapovalov"

Quote
<shapo...@email.com> wrote:
>Hi!

>I'm using ListView component in CBB 5 and when I try to clear it using
>either Items-.Clear() or Items->Delete() (in a loop) methods, it functions
>DEADLY slow. Clearing of ListView containing about 60 items takes about a
>second on my P-II-400 128M but I need, may be, a thousand items in the
>list... I noted this time vary depending on size of ListView - more size -
>more time it takes. Adding items into list is fast.

>What can I do to avoid this problem?

>Sergey Shapovalov.

You should disable repainting the listview while clearing the
listview:

ListView1->Items->BeginUpdate();
ListView1->Items->Clear();
ListView1->Items->EndUpdate();

Re:TListView->Items->Clear() is deadly slow


Sergey,

Quote
> What can I do to avoid this problem?

Are you using a virtual list view? For anything more than a few
hundred items it's something you should seriously consider. For more
information look up TListView::OnData in the help.

Andrue Cope
[Bicester, UK]

Other Threads