转载地址:https://zhidao.baidu.com/question/497293972425324804.html
现在使用
splitContainer1.GetType().GetProperty(“DoubleBuffered”, System.Reflection.BindingFlags.Instance | System.Reflection.BindingFlags.NonPublic).SetValue(splitContainer1, true, null);
splitContainer1.Panel2.GetType().GetProperty(“DoubleBuffered”, System.Reflection.BindingFlags.Instance | System.Reflection.BindingFlags.NonPublic).SetValue(splitContainer1.Panel2, true, null);
splitContainer1.Panel1.GetType().GetProperty(“DoubleBuffered”, System.Reflection.BindingFlags.Instance | System.Reflection.BindingFlags.NonPublic).SetValue(splitContainer1.Panel1, true, null);
闪烁明显改善,但是还存在。尤其是拖拽中间的分割线的时候。请问如何彻底消除闪烁现象?
重写一个控件继承 SplitContainer,在构造函数里加:
this.SetStyle(
ControlStyles.UserPaint |
ControlStyles.AllPaintingInWmPaint |
ControlStyles.OptimizedDoubleBuffer, true);
另外如果容器内部你还有别的容器控件(尤其是 Panel、GroupBox、甚至 PictureBox),这些子容器没启用双缓冲的话,SplitContainer 即使开了双缓冲也没用。