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
2010-09-15 21:14:12
By collection do you mean array?
Soo
2010-09-15 21:15:02
Anything that implements IList, could be an array if you will.
Darin Dimitrov
2010-09-15 21:17:09
@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
2010-09-15 21:32:27
[found it](http://meta.stackoverflow.com/questions/2115/text-formatting-now-allowed-in-comments-list-of-proven-and-disproven-abilities "found it")
Beth
2010-09-15 22:13:24