[2 days left] What’s wrong with your cloud strategy? Learn why multicloud solutions matter with Nimble Storage.Register Now

x
?
Solved

Populating ListView takes forever

Posted on 2003-11-30
4
Medium Priority
?
466 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 1000 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

[Webinar] Lessons on Recovering from Petya

Skyport is working hard to help customers recover from recent attacks, like the Petya worm. This work has brought to light some important lessons. New malware attacks like this can take down your entire environment. Learn from others mistakes on how to prevent Petya like worms.

Question has a verified solution.

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

This article introduced a TextBox that supports transparent background.   Introduction TextBox is the most widely used control component in GUI design. Most GUI controls do not support transparent background and more or less do not have the…
It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
Want to learn how to record your desktop screen without having to use an outside camera. Click on this video and learn how to use the cool google extension called "Screencastify"! Step 1: Open a new google tab Step 2: Go to the left hand upper corn…
Are you ready to place your question in front of subject-matter experts for more timely responses? With the release of Priority Question, Premium Members, Team Accounts and Qualified Experts can now identify the emergent level of their issue, signal…
Suggested Courses

656 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