using System.Windows.Forms;
using System.Drawing.Drawing2D;
namespace WindowsFormsApp13
public partial class MyCheckbox : PictureBox
protected override void OnPaint(PaintEventArgs pe)
Graphics g = pe.Graphics;
g.SmoothingMode = SmoothingMode.AntiAlias;
float width = g.VisibleClipBounds.Width;
float height = g.VisibleClipBounds.Height;
Pen p = new Pen(Color.Green, 3);
g.DrawLines(p, new PointF[] {
new PointF(width/2, height),
Pen p = new Pen(Color.Red, 3);
g.DrawLine(p, new PointF(0, 0), new PointF(width, height));
g.DrawLine(p, 0, height, width, 0);
Pen p = new Pen(Color.Blue, 3);
g.DrawRectangle(p, 0, 0, width, height);
protected override void OnClick(EventArgs e)
protected override void OnMouseEnter(EventArgs e)
protected override void OnMouseLeave(EventArgs e)