views:

28

answers:

2

I'm adding 50k~ish items to a list view and it refreshes each time (this is slowing it down big time). How can I disable the redrawing of the form, and enable it when it's done adding all of the items?

A: 

How about adding it to a collection and binding this collection to the DataSource property of the list control only once:

IList<Foo> items = FetchFoos();
myList.DataSource = items;

Of course if fetching 50k items is slow you might consider a BackgroundWorker to avoid freezing the UI (as a user I hate when my UI freezes).

Darin Dimitrov
By collection do you mean array?
Soo
Anything that implements IList, could be an array if you will.
Darin Dimitrov
+1  A: 

see this

Beth
@Beth: if you are not answering but rather just pointing somewhere else, this is better done by posting a comment to the question, rather than an answer.
Fredrik Mörk
OK. Now if I could only figure out how to embed a link in a comment...
Beth
[found it](http://meta.stackoverflow.com/questions/2115/text-formatting-now-allowed-in-comments-list-of-proven-and-disproven-abilities "found it")
Beth