473,729 Members | 2,149 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Speed issues with filling a list view

I was wondering how you guys would handle filling a list view with something
like 10,000 items which each have 10 sub items on them... there has to be
major speed issues with that right? Yet, applications like outlook and such
can retrieve and display tens of thousands of emails with virtually no
performance hit at all... how would we go about getting a .NET listview to
get similar performance? when I try to do what I said above, it takes about
15 seconds or more to fill it with that much information and that is just
random test data... not real life from a database data either
Nov 17 '05 #1
6 9049
Welcome to the world of threading!

Load the visible page, then continue to load the rest in another thread.

There is a good example in chapter 10 of:
http://www.apress.com/book/bookDisplay.html?bID=173

The source code is available for download.

"Brian Henry" <no****@nospam. com> wrote in message
news:OM******** ******@TK2MSFTN GP11.phx.gbl...
I was wondering how you guys would handle filling a list view with
something like 10,000 items which each have 10 sub items on them... there
has to be major speed issues with that right? Yet, applications like
outlook and such can retrieve and display tens of thousands of emails with
virtually no performance hit at all... how would we go about getting a .NET
listview to get similar performance? when I try to do what I said above, it
takes about 15 seconds or more to fill it with that much information and
that is just random test data... not real life from a database data either

Nov 17 '05 #2
I do not think that it is a listview that is used; rather, I think that the
control is a datagrid. I also think that only that which is visible plus a
few more are actually loaded on initial load. The rest of the data is
loaded on demand to match the scrollbar. Counts, and pointers are the only
thing loaded on initial load.

"Brian Henry" <no****@nospam. com> wrote in message
news:OM******** ******@TK2MSFTN GP11.phx.gbl...
I was wondering how you guys would handle filling a list view with
something like 10,000 items which each have 10 sub items on them... there
has to be major speed issues with that right? Yet, applications like
outlook and such can retrieve and display tens of thousands of emails with
virtually no performance hit at all... how would we go about getting a .NET
listview to get similar performance? when I try to do what I said above, it
takes about 15 seconds or more to fill it with that much information and
that is just random test data... not real life from a database data either

Nov 17 '05 #3
The best performance I have gotten from a ListView is via
ListView.Items. AddRange(x)
where x is an array of ListViewItems. With the data volume you have,
I think the way to go is a worker thread that creates an array of
ListViewItems, loads data into the array, and from time to time calls
AddRange and reinitializes. Be aware of the need to execute AddRange on gui
thread rather than on the worker thread.

Nov 17 '05 #4
"Brian Henry" <no****@nospam. com> schrieb:
I was wondering how you guys would handle filling a list view with
something like 10,000 items which each have 10 sub items on them... there
has to be major speed issues with that right? Yet, applications like
outlook and such can retrieve and display tens of thousands of emails with
virtually no performance hit at all... how would we go about getting a .NET
listview to get similar performance?


You may want to use a virtual listview:

<URL:http://www.ilypsys-systems.co.uk/ils1controls.zi p>

Note that .NET 2.0's listview control will support a virtual mode
('VirtualMode' property) which allows to display millions of items
blindingly fast.

--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://classicvb.org/petition/>

Nov 17 '05 #5
On Fri, 30 Sep 2005 13:52:02 -0700, "AMercer"
<AM*****@discus sions.microsoft .com> wrote:
The best performance I have gotten from a ListView is via
ListView.Items. AddRange(x)
where x is an array of ListViewItems. With the data volume you have,
I think the way to go is a worker thread that creates an array of
ListViewItem s, loads data into the array, and from time to time calls
AddRange and reinitializes. Be aware of the need to execute AddRange on gui
thread rather than on the worker thread.


I do agree that using AddRange is the fastest way. I will however
disagree about using a worker thread since the gain is minimal. In my
experience the majority of time will still be spent in the AddRange
method and not building the array.

Here is some modified sample code from one of my projects to use as a
base. Displaying 9600 items takes 1.5 seconds (which is acceptable for
me as a user of the program) on my Athlon XP 1700.

private void RefreshListView ()
{
listView.BeginU pdate();
listView.Items. Clear();
AddItemsToListV iew();
listView.EndUpd ate();
}

private void AddItemsToListV iew()
{
List<ListViewIt em> items = new List<ListViewIt em>();
foreach (Episode episode in filter.Execute( episodeList.Epi sodes))
items.Add(Creat eListViewItem(e pisode));
listView.Items. AddRange(items. ToArray());
}

private static ListViewItem CreateListViewI tem(Episode episode)
{
ListViewItem item = new ListViewItem(
new string[]
{
episode.Origina lAirdate.HasVal ue?
episode.Origina lAirdate.Value. ToShortDateStri ng():"",
episode.Show.Na me,
episode.Season. ToString(),
episode.Episode Number.ToString (),
episode.Title
});
item.ForeColor = EpisodeForeColo r(episode);
item.Tag = episode;
return item;
}

Even though I create lots of ListViewItems which contain a decent
amount of subitems(5). I still spend 90% of the time in the AddRange
method.

--
Marcus Andrén
Nov 17 '05 #6
wow you are right, doing an addrange increased our performance by a lot of
time. Before it took 4530 milliseconds to fill, now it only takes 635
milliseconds

"AMercer" <AM*****@discus sions.microsoft .com> wrote in message
news:E3******** *************** ***********@mic rosoft.com...
The best performance I have gotten from a ListView is via
ListView.Items. AddRange(x)
where x is an array of ListViewItems. With the data volume you have,
I think the way to go is a worker thread that creates an array of
ListViewItems, loads data into the array, and from time to time calls
AddRange and reinitializes. Be aware of the need to execute AddRange on
gui
thread rather than on the worker thread.

Nov 17 '05 #7

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

Similar topics

3
2146
by: Jeffrey Silverman | last post by:
Hi all, a request for opinions, please. I am designing a smallish application to manage members of several committees of a particula Organization. The structure of the system is as follows: theOrganization contains Committees which in turn contain People So theOrganization object is a list of Committee objects which are
15
2505
by: Guyon Morée | last post by:
Hi all, I am working on a Huffman encoding exercise, but it is kinda slow. This is not a big problem, I do this to educate myself :) So I started profiling the code and the slowdown was actually taking place at places where I didn't expect it. after I have created a lookup-table-dictionary with encodings like {'d':'0110', 'e':'01' etc} to encode the original text like this:
60
10144
by: Neil | last post by:
I have a situation with an ODBC linked view in an Access 2000 MDB with a SQL 7 back end. The view is scrolling very slowly. However, if I open the view in an ADP file, it scrolls quickly. I needed to use an ODBC link for the view because it needs to be editable. Otherwise, I would have used a pass-through query. In previous discussions about using an MDB file vs. an ADP file as a front end for SQL Server, the impression I got was that...
11
2163
by: Brian Henry | last post by:
Well here is the problem, I have a data set with about 9,000 to 20,000 people in it in the data table "people"... I am then reading it into a list view one at a time row by row... adding each person to the list view, well this works fine up to about 1,000 people then it start's to get really show putting the people in (a lot of process time used up)... does anyone know of any optimizations i could do to make this processess work a lot...
5
3675
by: Brian Henry | last post by:
I was wondering how you guys would handle filling a list view with something like 10,000 items which each have 10 sub items on them... there has to be major speed issues with that right? Yet, applications like outlook and such can retrieve and display tens of thousands of emails with virtually no performance hit at all... how would we go about getting a .NET listview to get similar performance? when I try to do what I said above, it takes...
2
2776
by: jphelan | last post by:
Ever since I successfully applied some techniques for increasing the speed of my 17 meg. Application; it has only made me hunger for more. First, let me list what I have done so far: 1. Split the application and database into front and back-ends, 2. Increased the load-time of my application by "pre-loading my heaviest forms when the database is initially opened, 3. When forms do open, under, "Filter Lookup" I use, "Never", 4. I set...
5
2122
by: Alexnb | last post by:
Hello I am sure most of you are familiar with py2exe. I am having a bit of a problem. See the program has a few pictures involved and the .ico it uses for the windows. However, the pictures are stored in the same directory as the source, something like: C:\Docs and settings\me\My docs\python\program. When I run the program for the interpreter, just as a .py, everything works just as it should. However, when I compile the main source as...
0
8761
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,...
0
9426
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. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
9280
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 captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
9142
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
8144
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...
1
6722
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6016
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
3238
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
3
2162
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.