Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

How can you speed up adding items to TListView?

201 views
Skip to first unread message

Grant Johnson

unread,
May 13, 1997, 3:00:00 AM5/13/97
to

I'm adding hundreds of items to a ListView control and as the number of
items in the list goes up the longer it takes to add the next item. Is
there a faster way to add items to a TListView? Or is there a better
control? Or maybe a better method to manage large items of lists?


Thanks

-grant
gra...@novell.com

Vincent Parrett

unread,
May 14, 1997, 3:00:00 AM5/14/97
to

I think it's
Mylistview.BeginUpdate

Mylistview.EndUpdate

if that doesn't work, try disabling it while updating, this should stop it
from redrawing

HTH

--
Vincent Parrett
Albury, NSW, Australia

Email : remove_ = antispam
Email : remove_...@albury.net.au_remove
Web : http://www.albury.net.au/~vparrett

Grant Johnson <Gra...@Novell.com> wrote in article
<3378e...@gronk.provo.novell.com>...

Thomas Hill

unread,
May 14, 1997, 3:00:00 AM5/14/97
to

"Grant Johnson" <Gra...@Novell.com> wrote:

>
>I'm adding hundreds of items to a ListView control and as the number of
>items in the list goes up the longer it takes to add the next item. Is
>there a faster way to add items to a TListView? Or is there a better
>control? Or maybe a better method to manage large items of lists?

One way is to create a TStringList, add all the items to that, the use the
ListBox.Items.Assign method to make your stringlist the list for the listbox.
Be sure to do the hourglass cursor thing, or put up a 'loading...' sign, or
something.....

>
>
>Thanks
>
>-grant
>gra...@novell.com
>
>


David Jameson

unread,
May 14, 1997, 3:00:00 AM5/14/97
to

Assuming you're trying to add them all at one time, use the BeginUpdate
and EndUpdate methods to stop the control from repainting each time an
item
is added.
I've seen advertisements for controls that claim to do a better job but
don't
remember any names offhand.

David Jameson

updating
Grant Johnson wrote:

> I'm adding hundreds of items to a ListView control and as the number
> of
> items in the list goes up the longer it takes to add the next item. Is
>
> there a faster way to add items to a TListView? Or is there a better
> control? Or maybe a better method to manage large items of lists?
>

> Thanks
>
> -grant
> gra...@novell.com


Baltic Advanced Technologies

unread,
May 15, 1997, 3:00:00 AM5/15/97
to

Grant Johnson wrote:
>
> I'm adding hundreds of items to a ListView control and as the number of
> items in the list goes up the longer it takes to add the next item. Is
> there a faster way to add items to a TListView? Or is there a better
> control? Or maybe a better method to manage large items of lists?
>
> Thanks
>
> -grant
> gra...@novell.com

Before adding call Items.BeginUpdate to prevent list contents frm
updating which needs a lotof time. After you finished call
Items.EndUpdate to refresh contents on screen.
******************************************
Baltic Advanced Technologies
Solutions for software developers
http://www.batsoft.com
We know you need the help.
Here it is!!!
OverPLAY,OverDIG,OptStyle and more...
******************************************

Vang

unread,
May 15, 1997, 3:00:00 AM5/15/97
to

In article <3378e...@gronk.provo.novell.com>,

"Grant Johnson" <Gra...@Novell.com> wrote:
>
>I'm adding hundreds of items to a ListView control and as the number of
>items in the list goes up the longer it takes to add the next item. Is
>there a faster way to add items to a TListView? Or is there a better
>control? Or maybe a better method to manage large items of lists?
>
>
>Thanks
>
>-grant
>gra...@novell.com
>
>

Turn the sort off. This will speed it up.

Peter Zaal

unread,
May 18, 1997, 3:00:00 AM5/18/97
to

If the items should be sorted, then add the items first to a
TStringList, then use the Sort method for the stringlist, then
add the Items to the ListView. This way, you dont have to set the
SortType property for the listview.
Before adding, do a ListView.Items.BeginUpdate, after adding do a
ListView.Items.EndUpdate.

---
Peter

Boris Herman

unread,
May 21, 1997, 3:00:00 AM5/21/97
to

Hi!

> In article <3378e...@gronk.provo.novell.com>,
> "Grant Johnson" <Gra...@Novell.com> wrote:
> >I'm adding hundreds of items to a ListView control and as the number of
> >items in the list goes up the longer it takes to add the next item. Is
> >there a faster way to add items to a TListView? Or is there a better
> >control? Or maybe a better method to manage large items of lists?

Set ListView's AllocBy property to a larger value. Help says:

The AllocBy property prepares a list view control for adding a large
number of items. Set AllocBy before adding a large number of items.
AllocBy enables a list view control to reallocate its internal data
structures only once rather than every time you add an item.

Bye,
Boris
--
Boris Herman, Sight & Sound Slovenia
E-mail: mailto:in...@sight-sound.si
WWW: http://www.sight-sound.si
ICQ: http://wwp.mirabilis.com/907377
ICQ-Add: http://wwp.mirabilis.com/cgi-bin/uinadd?to=907377

0 new messages