Double buffering control causes grey to appear
我有一个可以接受
1 2 3 4 5 6 7 | System.Reflection.PropertyInfo aProp = typeof(System.Windows.Forms.Control).GetProperty( "DoubleBuffered", System.Reflection.BindingFlags.NonPublic | System.Reflection.BindingFlags.Instance); aProp.SetValue(drawControl, true, null); |
添加此代码后,将绘制图像,然后立即将其替换为默认的灰色按钮背景色-就像系统在绘制我自己的内容一样。
我记得在某处看到一个属性,该属性指示系统从不绘制控件(这对我来说是完美的,因为我要用内容填充整个控件),但是现在找不到了。是否有这样的属性,如果有,该如何启用?
我正在将C#与.NET Framework 4.0版一起使用。
尝试将控件上的FlatStyle设置为FlatStyle.Standard(如果当前已将其设置为FlatStyle.System)。
(通过反射设置DoubleBuffered看起来也很可怕,但也许出于某些原因您需要这样做)