我想到了。事实证明,当 aTreeView内部的 a(可能另一个控件可能有相同的问题)SplitContainer导致闪烁问题时。我用一个非常简单的原型进行了尝试,一个Winform只有一个SplitContainer和一个TreeView容器的新原型,我已经可以看到某些节点上的闪烁。我尝试了很多东西,但似乎完成了这项工作的是:
this.SetStyle(ControlStyles.DoubleBuffer, true);
完全排除所有闪烁的另一件事是:
int style = NativeWinAPI.GetWindowLong(this.Handle, NativeWindowAPI.GWL_EXSTYLE);
style |= NativeWinAPI.WS_EX_COMPOSITED;
NativeWinAPI.SetWindowLong(this.Handle, NativeWinAPI.GWL_EXSTYLE, style);
两者都在Form_Load.
NativeWinAPI 类:
using System.Runtime.InteropServices;
internal static class NativeWinAPI
{
internal static readonly int GWL_EXSTYLE = -20;
internal static readonly int WS_EX_COMPOSITE = 0x02000000;
[DllImport("user32")]
internal static extern int GetWindowLong(IntPtr hWnd, int nIndex);
[DllImport("user32")]
internal static extern int SetWindowLong(IntPtr hWnd, int nIndex, dwNewLong);
}
这将完全停止在SplitContainer. 希望我可以帮助某人。