组合框无法使用双缓冲。在Windows窗体中,有没有其他方法可以避免闪烁?
我有一个Windows窗体,其中包含多个面板。根据我的菜单选择,我只显示一个面板。
我有一个图标面板、一个标题面板和一个组合框。根据该组合框所选项目,填充GridView1和2。当我使用键盘向下箭头快速选择组合框项目时,图标面板和标题面板始终重新绘制。我需要保持这两个面板不变。这两个面板会产生一些闪烁效果(即它们会闪烁或闪烁),而我正在更改组合框的选定索引。有没有办法避免这种闪烁?我尝试在表单构造器和表单加载事件中启用双缓冲,但没有成功。
InitializeComponent();
this.SetStyle(ControlStyles.DoubleBuffer, true);
this.SetStyle(ControlStyles.AllPaintingInWmPaint, true);
this.SetStyle(ControlStyles.UserPaint, true);
this.SetStyle(ControlStyles.SupportsTransparentBackColor, false);
this.SetStyle(ControlStyles.Opaque, false);
this.SetStyle(ControlStyles.OptimizedDoubleBuffer, true);
this.SetStyle(ControlStyles.ResizeRedraw, true);
我尝试在表单构造函数和表单加载事件中使用了这段代码。