我有一个自定义控件,其上有其他控件。当用户点击它时,我递归地遍历所有控件并将其背景颜色更改为蓝色。但是,当控件单独更改颜色时,我会遇到大量闪烁问题。我启用了双缓冲,但我怀疑它优化了我的绘图。我怀疑这可能不是做这种效果的最佳方式。更改背景时自定义控件闪烁
我该如何摆脱这种闪烁?或者有更好的方法来做到这一点?
我的电话的onclick:
ControlUtils.SetColorRecursive(this, Color.LightSteelBlue);
SetColorRecursive:
tCtl.SuspendLayout();
if (tCtl != null)
{
// Set Color
tCtl.BackColor = tColor;
foreach (Control tSubCtl in tCtl.Controls)
{
// Ignore the following
if (tSubCtl is TextBox) continue;
if (tSubCtl is ListBox) continue;
if (tSubCtl is NumericUpDown) continue;
// Recursively change sub-controls
SetColorRecursive(tSubCtl, tColor);
}
}
tCtl.ResumeLayout();
谷歌搜索产生的结果提到了一种称为合成的不同类型的双缓冲。任何人都知道这种方法? – MarkP