日期:2014-05-20 浏览次数:20890 次
Graphics g = label1.CreateGraphics();
            Pen p = new Pen(Color.Red, 1);
            p.DashStyle = DashStyle.Solid;
            g.DrawLine(p, 0, 0, 5, 5);
            g.Dispose();
        private void label1_Paint(object sender, PaintEventArgs e)
        {
            e.Graphics.DrawLine(Pens.Red, new Point(0, 5), new Point(10, 5));
        }
------解决方案--------------------
在label的paint事件中完成
private void label1_Paint(object sender, PaintEventArgs e)
{
   Pen p = new Pen(Color.Red, 1);
   p.DashStyle = DashStyle.Solid;
   e.Graphics.DrawLine(p, 0, 0, 5, 5);
   e.Dispose();
}
------解决方案--------------------