Listview (slow when adding items)

C

cybertof

Hello,

Is there a solution to the following problem :
When filling a listview (30 columns) with around 5000 items, it can take
easily 10 sec for the listview to be filled.

I have used BeginUpdate and SuspendLayout but no speed...

Here is a flavor of the code :

MyListView.BeginUpdate();
MyListView.SuspendLayout();
.....
....
(loop_fill)
ListViewItem MyItem = new ListViewItem(...parms...);
MyItem.SubItems.Add(...parms...);
MyItem.SubItems.Add(...parms...);
MyItem.SubItems.Add(...parms...);
....
MyListView.Items.Add(MyItem);
(loop_fill_end)
MyListView.EndUpdate();
MyListView.ResumeLayout();


But it is still slow...
Is the slowness of the listview a known issue ?
Any idea ?


Regards,
Cybertof.
 
C

cody

Is there a solution to the following problem :
When filling a listview (30 columns) with around 5000 items, it can take
easily 10 sec for the listview to be filled.


Adding items to a ListView is slow but using AddRange() instead of Add() can
help a bit.
Passing all subitems of a ListViewItem in form of an string[] might also
help speed things up.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top