在label中画一条线怎么就画不上呢
代码如下
- C# code
Graphics g = label1.CreateGraphics(); Pen p = new Pen(Color.Red, 1); p.DashStyle = DashStyle.Solid; g.DrawLine(p, 0, 0, 5, 5); g.Dispose();
[解决办法]
把上面的代码写在Label的OnPaint事件应该就没问题了
[解决办法]
- C# code
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();
}
[解决办法]