473,320 Members | 1,896 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

Listview (slow when adding items)

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.
Nov 16 '05 #1
2 9002
> 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.

--
cody

Freeware Tools, Games and Humour
http://www.deutronium.de.vu || http://www.deutronium.tk
Nov 16 '05 #2
cybertof <cy****************@gmx.net> wrote in message news:<MP************************@msnews.microsoft. com>...
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.


I had this same problem. A huge speed increase is to use AddRange()
instead of Add(). In your loop, collect all of your items into an
array. Then when the loop is finished, call
MyListView.Items.AddRange(MyItems) once.
Nov 16 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

6
by: Anushya | last post by:
Hi I am using Listview and inherited listview control overriding WndProc & PreProcessMessage in ListView. I need this to customize listview to display only the page the user scrolls to. Since i...
0
by: Anushya | last post by:
Hi I am using Listview and inherited listview control overriding WndProc & PreProcessMessage in ListView. I need this to customize listview to display only the page the user scrolls to. Since i...
6
by: VM | last post by:
How can I fill up a listview with text file contents? My listview has two columns and the first column fills up with a while loop: while (myString != null) { myString = sr.Readline();...
0
by: Ryan Dawson | last post by:
Hello. I am getting an error when trying to remove/access items inside of a listview: System.ArgumentOutOfRangeException: Specified argument was out of the range of valid values. Parameter...
18
by: mrshrinkray | last post by:
Are there any know bugs with the ListView in .NET 2? I'm having problems with an application that takes 15 seconds in 1.1, and now takes over a minute. The code in question uses: listViewItem =...
4
by: firefox | last post by:
Hola Foro!, tengo una rutina que permite agregar varios elementos o items de una sola vez en un ListView. Lo que sucede es que en el momento que se añaden los items al ListView se pone todo blanco,...
9
by: Kadett | last post by:
Hi all, I have following problem: I'm creating a ListView (Details) control at run-time and filling it with some records (let's say 10 000). This operation seems to be quite fast, but when I call...
3
by: RT | last post by:
Is there any way to make Listview items invisible or otherwise keep them from displaying? Seems like temporarily removing, then restoring later would be a severe runtime hit.
1
by: =?Utf-8?B?UmF5IE1pdGNoZWxs?= | last post by:
Hello, In my application I need to periodically remove all current items from a ListView and add a new set into it. The following abbreviated code contains the basic idea: private void...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.