前言:
今天在项目中遇到一个优化项问题,登录界面在Tab切换输入框时整个界面出现了闪动的问题,找了半天并且调试也没有发现问题原因,于是度之~
问题描述:
Winform程序界面切换闪屏。
问题解决:
将下面的代码复制到父窗体任意位置
protected override CreateParams CreateParams
{
get
{
CreateParams cp = base.CreateParams;
cp.ExStyle |= 0x02000000;
return cp;
}
}
问题原因:
A form that has a lot of controls takes a long time to paint. Especially the Button control in its default style is expensive. Once you get over 50 controls, it starts getting noticeable. The Form class paints its background first and leaves "holes" where the controls need to go. Those holes are usually white, black when you use the Opacity or TransparencyKey property. Then each control gets painted, filling in the holes. The visual effect is ugly and there's no ready solution for it in Windows Forms. Double-buffering can't s