Question

I have a ListView which sometimes I need to put around 10000 items in. ListViews don't really handle this well, and they lock up for a couple of seconds while they sort the items and draw them. If you add the items in individually, it's even worse, locking up for nearly a minute.

To get around this, I thought I'd try populating the ListView before I need to display it, but unfortunately it has other ideas. It only starts drawing when I turn the panel that contains the ListView visible, making the program hang for a couple of seconds.

Any ideas for how I can eliminate this delay? Or is there another component that's relatively easy to use that is better at showing large quantities of data?

Was it helpful?

Solution

You need to use the VirtualMode.

OTHER TIPS

Well. If you just want to load the content in the background you could try a thread to populate the ListView, which will let the form load.

I don't think you will get the pause if you put an Application.DoEvents(); when you are loading the items (which allows the form to redraw and receive events).

for (int ix=0; ix < 10000; ix ++)
{
 listView1.Items.Add(ix.ToString());
 Application.DoEvents();
}

I guess my suggestions are good if you aren't aware of VirtualMode

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top