代码如下,重绘但是没有用
protected override void OnPaint(System.Windows.Forms.PaintEventArgs e)
{
base.OnPaint(e);
Graphics g = e.Graphics;
g.SmoothingMode = SmoothingMode.AntiAlias;
SizeF DSize = g.MeasureString("√", new Font(new FontFamily("宋体"), 18));
this.Height = (int)DSize.Height;
Rectangle Outrect = new Rectangle(0, this.Height / 2 - 6, 12, 12);
Rectangle Inrect = new Rectangle(1, this.Height / 2 - 6 + 1, 10, 10);
GraphicsPath path = new GraphicsPath();
path.AddRectangle(Outrect);
g.DrawPath(new Pen(this.Enabled ? CheckColor : Color.Silver), path);
g.FillPath(new SolidBrush(CheckBackColor), path);
if (Checked)
{
g.DrawString("√", new Font(new FontFamily("宋体"), 18), new SolidBrush(this.Enabled ? CheckColor : Color.Silver), new PointF(6 - DSize.Width / 2, this.Height / 2 - Height / 2 - 1));
}
} |