protected override void OnPaintBackground(PaintEventArgs e)
{
Rectangle r = new Rectangle(0, 0, this.Size.Width, this.Size.Height);
LinearGradientBrush lb = new LinearGradientBrush(r, Color.Red, Color.Yellow, LinearGradientMode.BackwardDiagonal);
e.Graphics.FillRectangle(lb, r);//使用画刷填充指定区域
}
protected override void OnPaint(PaintEventArgs e)
{
e.Graphics.DrawBezier(curvepen, pt1, pt2, pt3, pt4);//画四个圆点代表每个点
e.Graphics.DrawEllipse(curvepen, pt1.X - 1, pt1.Y - 1, 3, 3);
e.Graphics.DrawEllipse(curvepen, pt2.X - 1, pt2.Y - 1, 3, 3);
e.Graphics.DrawEllipse(curvepen, pt3.X - 1, pt3.Y - 1, 3, 3);
e.Graphics.DrawEllipse(curvepen, pt4.X - 1, pt4.Y - 1, 3, 3);
base.OnPaint(e);
}
例程里面的东西
疑惑的地方在 base.OnPaint(e);base.OnpaintBackground(e);
若是在onpaintbackground中加入base.OnpaintBackground(e);则在运行后form的background没有改变颜色
删掉都能够显示修改的信息
在onpaint中 base.OnPaint(e);存在与否则没有对于绘制的贝塞尔曲线有影响
{
Rectangle r = new Rectangle(0, 0, this.Size.Width, this.Size.Height);
LinearGradientBrush lb = new LinearGradientBrush(r, Color.Red, Color.Yellow, LinearGradientMode.BackwardDiagonal);
e.Graphics.FillRectangle(lb, r);//使用画刷填充指定区域
}
protected override void OnPaint(PaintEventArgs e)
{
e.Graphics.DrawBezier(curvepen, pt1, pt2, pt3, pt4);//画四个圆点代表每个点
e.Graphics.DrawEllipse(curvepen, pt1.X - 1, pt1.Y - 1, 3, 3);
e.Graphics.DrawEllipse(curvepen, pt2.X - 1, pt2.Y - 1, 3, 3);
e.Graphics.DrawEllipse(curvepen, pt3.X - 1, pt3.Y - 1, 3, 3);
e.Graphics.DrawEllipse(curvepen, pt4.X - 1, pt4.Y - 1, 3, 3);
base.OnPaint(e);
}
例程里面的东西
疑惑的地方在 base.OnPaint(e);base.OnpaintBackground(e);
若是在onpaintbackground中加入base.OnpaintBackground(e);则在运行后form的background没有改变颜色
删掉都能够显示修改的信息
在onpaint中 base.OnPaint(e);存在与否则没有对于绘制的贝塞尔曲线有影响
你可以先让base.onpaint,再执行你的代码