Solved

Populating ListView takes forever

Posted on 2003-11-30
4
456 Views
Last Modified: 2010-08-05
I have a listView that I am adding a few thousand items to.  The first time I do it, it takes a few seconds, which is fine.  

When I reload the data, it takes too long when adding the items to the listView.  

I have sorters that sort based on columns when the headers are clicked.  I am removing the sorters from the the handlers, for the column clicking and then calling items.Clear() and adding all of the thousand or so items back in.  I don't know that this is doing anything, however.  It was taking 50 seconds reload.  Then I removed the sorters and called BeginUpdate() and EndUpdate().  Now it takes about 9 seconds.  Is there anything else I can do to speed this up?
0
Comment
Question by:jjacksn
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
4 Comments
 
LVL 4

Expert Comment

by:MrGhost
ID: 9848883
Why don't you just debug your application, so you can see which part of your code is slow?
0
 
LVL 20

Accepted Solution

by:
TheAvenger earned 250 total points
ID: 9848974
BeginUpdate and EndUpdate are actually what you could do to speed up (you did it already). Now try calling the methods in this order:

BeginUpdate()
items.Clear()
remove sorters
add items
re-add sorters (if needed, but this can also slow down)
EndUpdate

The way you do it (first remove sorters, then clear the items) could probably ask the view to resort the items in the default sorting they have which takes some time.

If you call all these methods in this order, I think this is the best you can get from the speed of the list view with so many items in it.
0
 
LVL 5

Author Comment

by:jjacksn
ID: 9851201
Mr Ghost, I'm actually away from my dev studio, and I can't replicate the behavoir until I am back next week.

If I hide the form while I am doing this, would this help?  I thought beginUpdate dold the control not to redraw itself?  When it is quick when the program is first loading, the control is not visible.
0
 
LVL 20

Expert Comment

by:TheAvenger
ID: 9851264
No, don't hide the form, it will not help. The first time you load the form, you con't have the sorters sorting anything. That's why I think the sorters are the problem...
0

Featured Post

Online Training Solution

Drastically shorten your training time with WalkMe's advanced online training solution that Guides your trainees to action. Forget about retraining and skyrocket knowledge retention rates.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Summary: Persistence is the capability of an application to store the state of objects and recover it when necessary. This article compares the two common types of serialization in aspects of data access, readability, and runtime cost. A ready-to…
Calculating holidays and working days is a function that is often needed yet it is not one found within the Framework. This article presents one approach to building a working-day calculator for use in .NET.
If you're a developer or IT admin, you’re probably tasked with managing multiple websites, servers, applications, and levels of security on a daily basis. While this can be extremely time consuming, it can also be frustrating when systems aren't wor…
Michael from AdRem Software outlines event notifications and Automatic Corrective Actions in network monitoring. Automatic Corrective Actions are scripts, which can automatically run upon discovery of a certain undesirable condition in your network.…

724 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question