473,544 Members | 1,809 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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.Begi nUpdate();
MyListView.Susp endLayout();
.....
....
(loop_fill)
ListViewItem MyItem = new ListViewItem(.. .parms...);
MyItem.SubItems .Add(...parms.. .);
MyItem.SubItems .Add(...parms.. .);
MyItem.SubItems .Add(...parms.. .);
....
MyListView.Item s.Add(MyItem);
(loop_fill_end)
MyListView.EndU pdate();
MyListView.Resu meLayout();
But it is still slow...
Is the slowness of the listview a known issue ?
Any idea ?
Regards,
Cybertof.
Nov 16 '05 #1
2 9022
> 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.micro soft.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.Begi nUpdate();
MyListView.Susp endLayout();
....
...
(loop_fill)
ListViewItem MyItem = new ListViewItem(.. .parms...);
MyItem.SubItems .Add(...parms.. .);
MyItem.SubItems .Add(...parms.. .);
MyItem.SubItems .Add(...parms.. .);
....
MyListView.Item s.Add(MyItem);
(loop_fill_end)
MyListView.EndU pdate();
MyListView.Resu meLayout();
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.Item s.AddRange(MyIt ems) once.
Nov 16 '05 #3

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

Similar topics

6
2614
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 am populating listview with more than 200,000 items. It is too slow and tried virtual listview. But that doesnot allow me to add images in the...
0
489
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 am populating listview with more than 200,000 items. It is too slow and tried virtual listview. But that doesnot allow me to add images in the...
6
4621
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(); listView1.Items.Add (myString); } Is there a way I can fill up the second column this easily? Thw way I'm currently doing it is using the subitems...
0
1131
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 name: '500' is not a valid value for 'displayIndex'. I only remove item 500 from the listview if the number of items is greater than 500 (so it...
18
1940
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 = this.listView1.Items.Add(...) followed by 7 calls to listViewItem.SubItems.Add(...)
4
3852
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, cuando se terminan de agregar los items vuelve a su estado normal. Como impido que esto suceda ?. Gracias Mil.
9
4467
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 Controls.Add(list), where list is my ListView control, then program hangs for minute. It seems like this time depends on number of records added to...
3
7635
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
8338
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 FillListViewFromFile(string path) {
0
7413
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
0
7356
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language...
0
7597
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. ...
0
7752
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
1
7358
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
0
5894
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
0
4902
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
0
3396
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
1831
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system

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.