Hi

When i have my 144 items to display in my listview it is very fast (not seeing it
but when i have my 2204 items (it's "just" about 20 times more) it take
about half a minute to display the items
the code looks like this

for (int row=0;row<sucheErgebnisse.rowData.Count;row++

rowData = (String[])sucheErgebnisse.rowData[row]

item = new ListViewItem(rowData[0])
for (int sub=0;sub<rowData.Length-1;sub++

item.SubItems.Add(rowData[1+sub])

this.listView1.Items.Add(item)


as you see from a class sucheErgebnisse i take the String arra
and write it's content in an item, which will be added to the listView

any suggestions why this is so slow, or how to do it faster
(in explorer file displaying is also faster

thanks for help

nic
}

Re: Adding Items to ListView too slow, please help by Marc

Marc
Fri May 14 16:23:40 CDT 2004

Try using SuspendLayout before starting the addition and ResumeLayout after
you are done adding your items.

--
Marc Butenko
mbutenko@bresnan.net



"Nick" <nick@winger.at> wrote in message
news:B8A17DEB-7EA9-4D72-8868-4F23E42C60EE@microsoft.com...
> Hi !
>
> When i have my 144 items to display in my listview it is very fast (not
seeing it)
> but when i have my 2204 items (it's "just" about 20 times more) it takes
> about half a minute to display the items.
> the code looks like this:
>
> for (int row=0;row<sucheErgebnisse.rowData.Count;row++)
> {
> rowData = (String[])sucheErgebnisse.rowData[row];
>
> item = new ListViewItem(rowData[0]);
> for (int sub=0;sub<rowData.Length-1;sub++)
> {
> item.SubItems.Add(rowData[1+sub]);
> }
> this.listView1.Items.Add(item);
> }
>
> as you see from a class sucheErgebnisse i take the String array
> and write it's content in an item, which will be added to the listView.
>
> any suggestions why this is so slow, or how to do it faster ?
> (in explorer file displaying is also faster)
>
> thanks for help !
>
> nick
> }



Re: Adding Items to ListView too slow, please help by hirf-spam-me-here

hirf-spam-me-here
Fri May 14 16:55:27 CDT 2004

* "Marc Butenko" <mbutenko@state.mt.us> scripsit:
> Try using SuspendLayout before starting the addition and ResumeLayout after
> you are done adding your items.

When adding items, no layouting is done.

--
Herfried K. Wagner [MVP]
<URL:http://dotnet.mvps.org/>

Re: Adding Items to ListView too slow, please help by Marc

Marc
Mon May 17 10:19:54 CDT 2004

My bad....I was thinking about the BeginUpdate and EndUpdate methods.

Whoops!

--
Marc Butenko
mbutenko@bresnan.net



"Herfried K. Wagner [MVP]" <hirf-spam-me-here@gmx.at> wrote in message
news:2gktj3F42bkmU1@uni-berlin.de...
> * "Marc Butenko" <mbutenko@state.mt.us> scripsit:
> > Try using SuspendLayout before starting the addition and ResumeLayout
after
> > you are done adding your items.
>
> When adding items, no layouting is done.
>
> --
> Herfried K. Wagner [MVP]
> <URL:http://dotnet.mvps.org/>



Re: Adding Items to ListView too slow, please help by hirf-spam-me-here

hirf-spam-me-here
Mon May 17 10:33:53 CDT 2004

* "Marc Butenko" <mbutenko@state.mt.us> scripsit:
> My bad....I was thinking about the BeginUpdate and EndUpdate methods.

When adding multiple items, that's the way to go.

> Whoops!

;-)

--
Herfried K. Wagner [MVP]
<URL:http://dotnet.mvps.org/>

Re: Adding Items to ListView too slow, please help by nick

nick
Mon May 17 13:06:05 CDT 2004

Hi

Well, I am adding multiple items ? and subitems
so what should i do ? :-

nick

Re: Adding Items to ListView too slow, please help by AlexS

AlexS
Mon May 17 13:10:22 CDT 2004

Hi, Nick

You might have 2 reasons:
- redraw is slowing down adding - and redraw is caused by every add
operation
- sorting (internal)
- add loop itself

For first reason - use BeginUpdate before starting updating contents of
listview and EndUpdate when you finish.
For sorting - you might need to check how you sort items in listviews. On my
machine for example, custom sorting slows down filling process to approx 100
items per second.
You might need to check also add loop - do you some heavy processing inside
for added items?

HTH
Alex

"Nick" <nick@winger.at> wrote in message
news:E11DA802-9A7E-4CBB-AF4A-65D54DC5F2F5@microsoft.com...
> Hi !
>
> Well, I am adding multiple items ? and subitems ?
> so what should i do ? :-)
>
> nick



Re: Adding Items to ListView too slow, please help by nick

nick
Mon May 17 14:06:03 CDT 2004

Well, hi Alex

i must say i have forgotten to mention one important thing
the items as it looks are added very fast, like a few seconds
because the scrollbar at the side of the listview is going small (the move rectangle
continously, and stays at it's size for this long time and nothing happens
it's like there is some loop it calls which does unnecessasry thing
and then suddenly (nothing happens with the scrollbar) the items appear..