在窗体的构造函数写下如下代码:
public FrmSearch() { //设置窗体的双缓冲 this.SetStyle(ControlStyles.OptimizedDoubleBuffer | ControlStyles.ResizeRedraw | ControlStyles.AllPaintingInWmPaint, true); this.UpdateStyles(); InitializeComponent(); //利用反射设置DataGridView的双缓冲 Type dgvType = this.dataGridView1.GetType(); PropertyInfo pi = dgvType.GetProperty("DoubleBuffered", BindingFlags.Instance | BindingFlags.NonPublic); pi.SetValue(this.dataGridView1, true, null); }
本文介绍如何在窗体的构造函数中设置窗体及其DataGridView控件的双缓冲功能,通过使用反射来提高界面的绘制效率,减少闪烁。

7980

被折叠的 条评论
为什么被折叠?



