注:VB.NET和C#系出同源,本方法同样适用VB.NET!
看过来吧,ListViewNF是你的对症良药!
只需几句话,你的视界将如此不同!
1、新建一个C# 类,命名为ListViewNF(NF=Never/No Flickering)
2、复制如下代码
class ListViewNF : System.Windows.Forms.ListView
{
public ListViewNF()
{
// Activate double buffering
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);
}
}
}
修改你的WinForm对应的xxxx.Design.cs,将系统默认生成的System.Windows.Forms.ListView改为ListViewNF即可。
祝好运!