473,652 Members | 3,045 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 9028
> 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
2621
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 listview. So now trying to list only the page user scrolls to.
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 listview. So now trying to list only the page user scrolls to.
6
4627
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 property to add it. Unfortunately,
0
1137
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 removes the last item). Also, I am updating items in the listview with code:
18
1952
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
3856
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
4478
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 control. So probably when adding control to my form, those records are actualy added at this time...
3
7641
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
8347
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
8367
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 usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8279
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 synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
1
8467
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 most users, this new feature is actually very convenient. If you want to control the update process,...
0
8589
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
7302
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 launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
5619
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 into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
1
2703
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
1
1914
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
2
1591
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.