我想知道什么时候应该调用base.OnPaint,当我们重写OnPaint在Windows窗体程序中?什么时候应该调用base.OnPaint()当我们
什么我做的是:
private void Form1_Paint(object sender, PaintEventArgs e)
{
// If there is an image and it has a location,
// paint it when the Form is repainted.
base.OnPaint(e);
}
我得到stackoerflowexception,为什么呢?
如果您希望在重写方法的“其他绘图命令”之后引发Paint事件,该怎么办? – mbeckish 2013-01-18 18:43:09
@mbeckish你可以在你自己的图纸之后轻松调用base方法,但是结果取决于控件的类型以及它在OnPaint方法中的作用。你应该知道,控制可以绘制你刚刚绘制的内容。希望擦除背景不会发生在'OnPaint'方法中,而是'OnPaintBackground'方法中。 – 2013-01-19 06:19:21