自制控件

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);存在与否则没有对于绘制的贝塞尔曲线有影响
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值