标签:
for (int j = 0; j < name.Count; j++)
{
Label lb = new Label();
lb.Paint+=new PaintEventHandler(lb_Paint);
}
///绘画事件
private void lb_Paint(object sender, PaintEventArgs e)
{
Label lb = sender as Label;
DrawRoundRect(e.Graphics, lb);
}
///画出边框
private void DrawRoundRect(Graphics graphics, Label label)
{
float X = float.Parse(label.Width.ToString()) - 1;
float Y = float.Parse(label.Height.ToString()) - 1;
PointF[] points = { new PointF(2,0),
new PointF(X-2,0),
new PointF(X-1,1),
new PointF(X,2),
new PointF(X,Y-2),
new PointF(X-1,Y-1),
new PointF(X-2,Y),
new PointF(2,Y),
new PointF(1,Y-1),
new PointF(0,Y-2),
new PointF(0,2),
new PointF(1,1)};
GraphicsPath path = new GraphicsPath();
path.AddLines(points);
Pen pen = new Pen(Color.FromArgb(150, Color.Black), 1);
pen.width=5 //画笔的宽度,即边框的宽度
pen.DashStyle = DashStyle.Solid;
graphics.DrawPath(pen, path);
}
标签:
原文地址:http://www.cnblogs.com/vichin/p/5666560.html