/// <summary>
///双缓冲DataGridView,解决闪烁
/// </summary>
class DoubleBufferListView : DataGridView
{
public DoubleBufferListView()
{
SetStyle(ControlStyles.DoubleBuffer | ControlStyles.OptimizedDoubleBuffer | ControlStyles.AllPaintingInWmPaint, true);
UpdateStyles();
}
}
然后在DataGridView所在窗体的InitializeComponent方法中,更改控件类型实例化语句为:
//this.dataGridView1 = new System.Windows.Forms.DataGridView(); (屏蔽掉)
this.dataGridView1 = new DoubleBufferListView();
**///////////////////////////////////////////////////////////////////////////////////////////////
/// <summary>
///双缓冲ListView ,解决闪烁
/// </summary>
class DoubleBufferListView : ListView
{
public DoubleBufferListView()
{
SetStyle(ControlStyles.DoubleBuffer | ControlStyles.OptimizedDoubleBuffer | ControlStyles.AllPaintingInWmPaint, true);
UpdateStyles();
}
}
然后在ListView 所在窗体的InitializeComponent方法中,更改控件类型实例化语句为:
//this.listView1 = new System.Windows.Forms.ListView(); (屏蔽掉)
this.listView1 = new DoubleBufferListView();