473,503 Members | 2,197 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 9028
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**************@TK2MSFTNGP11.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**************@TK2MSFTNGP11.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.zip>

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*****@discussions.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
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.


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.BeginUpdate();
listView.Items.Clear();
AddItemsToListView();
listView.EndUpdate();
}

private void AddItemsToListView()
{
List<ListViewItem> items = new List<ListViewItem>();
foreach (Episode episode in filter.Execute(episodeList.Episodes))
items.Add(CreateListViewItem(episode));
listView.Items.AddRange(items.ToArray());
}

private static ListViewItem CreateListViewItem(Episode episode)
{
ListViewItem item = new ListViewItem(
new string[]
{
episode.OriginalAirdate.HasValue?
episode.OriginalAirdate.Value.ToShortDateString(): "",
episode.Show.Name,
episode.Season.ToString(),
episode.EpisodeNumber.ToString(),
episode.Title
});
item.ForeColor = EpisodeForeColor(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*****@discussions.microsoft.com> wrote in message
news:E3**********************************@microsof t.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
2131
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:...
15
2486
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...
60
10078
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...
11
2141
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...
5
3655
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,...
2
2733
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...
5
2109
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...
0
7205
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,...
0
7287
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,...
1
7008
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...
0
7467
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...
1
5022
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...
0
4688
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...
0
3168
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
746
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
399
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...

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.