在对datagridview使用双缓存时,出现扩展方法必须在非泛型静态类中定义,我对这个不太理解,请解
{
public Form6()
{
InitializeComponent();
Type type = dataGridView1.GetType(); PropertyInfo pi = type.GetProperty("DoubleBuffered", BindingFlags.Instance | BindingFlags.NonPublic); pi.SetValue(dataGridView1, true, null);
}
public static void SetDoubleBuffered(this DataGridView dgv, bool b)
{
var dgvType = dgv.GetType();
var pi = dgvType.GetProperty("DoubleBuffered", BindingFlags.Instance | BindingFlags.NonPublic);
pi.SetValue(dgv, b, null);
}
{
public Form6()
{
InitializeComponent();
Type type = dataGridView1.GetType(); PropertyInfo pi = type.GetProperty("DoubleBuffered", BindingFlags.Instance | BindingFlags.NonPublic); pi.SetValue(dataGridView1, true, null);
}
public static void SetDoubleBuffered(this DataGridView dgv, bool b)
{
var dgvType = dgv.GetType();
var pi = dgvType.GetProperty("DoubleBuffered", BindingFlags.Instance | BindingFlags.NonPublic);
pi.SetValue(dgv, b, null);
}
{
public static void SetDoubleBuffered(this DataGridView dgv, bool b)
{
//...
}
}
protected override void OnPaint(PaintEventArgs e)
{
base.OnPaint(e);
ControlPaint.DrawBorder(e.Graphics, this.ClientRectangle, this.StateCommon.DataCell.Border.Color1, 1, ButtonBorderStyle.Solid, this.StateCommon.DataCell.Border.Color1, 1, ButtonBorderStyle.Solid, this.StateCommon.DataCell.Border.Color1, 1, ButtonBorderStyle.Solid, this.StateCommon.DataCell.Border.Color1, 1, ButtonBorderStyle.Solid); }
如果拖动水平滚动条,就出现无数的线条。应问应该如何做,谢谢了