我有一个面板,里面有多个面板。我已将主面板中的 OnPaint 覆盖为以下内容:
protected override void OnPaint(PaintEventArgs e)
{
Graphics graph = e.Graphics;
graph.Clear(Color.Black);
InvokePaintBackground(this, e);
graph.ScaleTransform(scale, scale);
foreach (childPanel child in childPanels)
{
child.onPaint(this, e);
}
graph.ResetTransform();
}
我遇到的问题是第一个控件(点 0 中的控件)的 onPaint 函数被调用了两次,所以我得到了两个版本的子面板,一个有缩放,一个没有。第二个 onPaint 似乎是由子控件本身调用的。
我怎样才能让它不这样做?