0

I am using a listview (listView1) which is flickering when i populate data into it(adding 10 lines in every second).

How can I enable double buffer property to make it flicker free.

Please give me step by step instructions. I am new to c#.

Jake
  • 1,560
  • 2
  • 17
  • 25
  • 1
    posible dupliacte http://stackoverflow.com/questions/87795/how-to-prevent-flickering-in-listview-when-updating-a-single-listviewitems-text – DragonZero Nov 15 '13 at 10:51
  • I tried this. But since i am populating very fast, it is freezing my application.. – Jake Nov 15 '13 at 11:25
  • can you post sample code, so we can see what is going on? – DragonZero Nov 15 '13 at 11:27
  • My application is connected to an external hardware. The hardware will pump huge amount of messages(~100 lines/ second) to the application. I am writing this in to listView. I am using the same code to enable double buffering and calling 'ListViewHelper.EnableDoubleBuffer(listView1);' upon checking a checkBox. Without double buffering, the app work good but the listview flicker too much. – Jake Nov 15 '13 at 11:33

2 Answers2

1

At 100 lines per second, you are going to need double buffering and virtual mode.

Double buffering requires subclassing a ListView and setting the DoubleBuffered protected property. Virtual mode requires setting VirtualSize to the number of rows and then responding the RetrieveVirtualItem event.

You should seriously consider using ObjectListView which is an open source wrapper around the .NET ListView that solves LOTS of problems so you don't have to.

Grammarian
  • 6,774
  • 1
  • 18
  • 32
0

One option here, would be to only update the listview datasource, so that your not directly accessing your control, only the underlying datasource.

DataTable dt = new DataTable();
//load the Datatable with items from your external hardware connection.
myListView.datasource = dt;

Then you only update the DataTable, not the control's list of items. With double buffering, you should see the affect you require.

Lastly, 100 listview items per second is a lot, do you need to have this many items in the listview? I would suggest filtering this list to only items you need at the time, will make it perform much better.

DragonZero
  • 810
  • 5
  • 8