代码说话:
dgvPosition就是需要避免闪烁的DataGridView
主要是加2段代码
1.SetStyle
2.datagridview设置DoubleBuffered属性为True
public AccountPositionControl()
{
this.SetStyle(ControlStyles.OptimizedDoubleBuffer | ControlStyles.ResizeRedraw | ControlStyles.AllPaintingInWmPaint, true);
this.UpdateStyles();
InitializeComponent();
dgvPosition.GetType().GetProperty("DoubleBuffered",BindingFlags.Instance | BindingFlags.NonPublic)
.SetValue(dgvPosition, true, null);
}