473,327 Members | 1,976 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,327 software developers and data experts.

Help! Populating a listview takes ages!!

All very simple app which loads a log file, parses it and displays the lines
in a listview.
I was playing about with some largeish files 800K and I noticed that the app
would never return control, it would just sit and consume 100% CPU for
aslong as I could be bothered to wait before I pskill's the app.

Anyway I was playing and found that even the code below takes a matter of
minutes to populate the control:

listView_Details.BeginUpdate();

for( int i = 0; i < 10000; i++ )
{
ListViewItem l = listView_Details.Items.Add( "Hello" );
l.SubItems.Add( "Hello" );
l.SubItems.Add( "Hello" );
l.SubItems.Add( "Hello" );
}

listView_Details.BeginUpdate();

Can somone, please anyone tell me how I can speed this operation up.

Thanks
PT

Nov 17 '05 #1
3 1218


Paul Tomlinson wrote:
All very simple app which loads a log file, parses it and displays the lines
in a listview.
ListView's Add is O(n^2).
Can somone, please anyone tell me how I can speed this operation up.


As a workaround you can collect all the items in a ListViewItem[] and
use AddRange.

--
Helge Jensen
mailto:he**********@slog.dk
sip:he**********@slog.dk
-=> Sebastian cover-music: http://ungdomshus.nu <=-
Nov 17 '05 #2
> ListView's Add is O(n^2).

What do you mean "ListView's Add is O(n^2)"???
Nov 17 '05 #3


Paul Tomlinson wrote:
ListView's Add is O(n^2).
What do you mean "ListView's Add is O(n^2)"???


It's a computer science term that (very roughly) means "doing it n times
takes n^2 effort". (n^2 means n*n here, it's just notation).

So if calling Add 1000 times takes roughly 1000t, then calling it 2000
times taks roughly 4000t, and 3000 times takes rougly 9000t, 4000 times
takes 16000t, and your 10000 times would take 100000t.

t is any arbitry timeunit here; ns, ms, ...

--
Helge Jensen
mailto:he**********@slog.dk
sip:he**********@slog.dk
-=> Sebastian cover-music: http://ungdomshus.nu <=-
Nov 17 '05 #4

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

Similar topics

1
by: cloverme | last post by:
Hi, I need help populating a listbox from a database on a webform. I created a an access database with a table, fields and data. Then I created a WebForm in vb.net and added a DropDownList...
14
by: Alex | last post by:
Hi, I use pg_restore to load a previously dumped database. (10mil records). the load of the data runs quite fast but when starting creating the triggers for foreign keys it takes forever. Isnt...
0
by: Martin Streller | last post by:
Hello, The code below represents a simple ownerdrawn, Listview class in C#. Its purpose is to avoid the flicker of the MS ListView. So I can't fall back to their one. Does anybody know why I...
0
by: MrNobody | last post by:
I would like to have a ListView where the user can right-lick on any row to have options specific to that row, then also be able to right-click on the column header to get a different menu....
2
by: MikeY | last post by:
Hi all, I am coding window forms in C#. My problem is this: I have created a "Check ListView" or a 'ListView' with checkbox's. I have populated the it with my files from my folders, mps, txt,...
6
by: ReMEn | last post by:
I was wondering how I can use a listview effectively in managed c++ ..net. Basically I'm trying to get the index of the selected item in the list view, then get the "tag" attribute of that item to...
3
by: luna | last post by:
theres no errors in my code - but it does nothing at all - its supposed to be populating text boxes!! any ideas ? (im am pretty new to all this) If Not Page.IsPostBack Then Dim search As...
4
by: Bill2k | last post by:
Could someone please give me an example of using the addhandler statement with the listview item click event. Also, if I could get an example of what the eventhandler would look like. Thanks in...
0
by: svx | last post by:
Hello, I am painting individual rows in a ListView control with different colors, depending on state. I am also using a SmallImageList in Detail view. When I set the...
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
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
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: 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.