首先,自定義一個類ListViewNF,繼承自 System.Windows.Forms.ListView
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 |
using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Windows.Forms; namespace 你的名稱空間 { class ListViewNF : System.Windows.Forms.ListView { public ListViewNF() { // 開啓雙緩衝 this.SetStyle(ControlStyles.OptimizedDoubleBuffer | ControlStyles.AllPaintingInWmPaint, true); // Enable the OnNotifyMessage event so we get a chance to filter out // Windows messages before they get to the form's WndProc this.SetStyle(ControlStyles.EnableNotifyMessage, true); } protected override void OnNotifyMessage(Message m) { //Filter out the WM_ERASEBKGND message if (m.Msg != 0x14) { base.OnNotifyMessage(m); } } } }
|
DoubleBufferListView doubleBufferListView1= new DoubleBufferListView();