UmairKhan

population of listview using background worker is not under my control, when it comes to more then 1000 records to be populated it starts flikering, it seems like there is a problem i guess the listview refreshes it self again and again and the visual effect it gives is not acceptable by eye. when i use framwork 1.1 using thread to populate listview it fills smoothly just like a water fall. cant it be done on 2.0


Re: Windows Forms General populating listview smoothly

Zhi-Xin Ye - MSFT

You can enable the double buffer for the ListView by SetStyle method like this

class myList : ListView

{

public myList()

{

this.SetStyle(ControlStyles.OptimizedDoubleBuffer,true);

}

}

Use this inherited ListView instead of the standard one would reduce the flicker.






Re: Windows Forms General populating listview smoothly

BinaryCoder

Also, consider the following from http://msdn2.microsoft.com/en-us/library/system.windows.forms.listview.beginupdate.aspx

The preferred way to add multiple items to a ListView is to use the AddRange method of the ListView.ListViewItemCollection (accessed through the Items property of the ListView). This enables you to add an array of items to the list in a single operation. However, if you want to add items one at a time using the Add method of the ListView.ListViewItemCollection class, you can use the BeginUpdate method to prevent the control from repainting the ListView each time an item is added. Once you have completed the task of adding items to the control, call the EndUpdate method to enable the ListView to repaint. This way of adding items can prevent flickered drawing of the ListView when a large number of items are being added to the control.