日期:2014-05-18 浏览次数:21138 次
public partial class MyLabel : Label
{
public MyLabel()
{
InitializeComponent();
}
protected override void OnPaint(PaintEventArgs e)
{
base.OnPaint(e);
Rectangle rect = this.ClientRectangle;
rect.Inflate(-2, -2);
using (Pen pen = new Pen(Color.Red, 3))
e.Graphics.DrawRectangle(pen, rect);
}
}
------解决方案--------------------
同上····原因是你画的画条左上会占用一象素,而下边就会多出一像素出来。