winfrom中如何给两个lable中间画虚线。
我这一共五个lable例如
2
3 1 4
5
在他们中间分别加上虚线,5个lable在panel中。谢谢。谢谢 --------------------编程问答-------------------- 用Visual Basic Power Pack组中的Line控件,设置线形为虚线。 --------------------编程问答-------------------- 硬编码,不知道对楼主是否有帮助
void panel1_Paint(object sender, PaintEventArgs e)
{
RenderLines(e.Graphics);
}
public void RenderLines(Graphics g)
{
List<PointF> points = new List<PointF>();
points.Add(lbl_2.Location);
points.Add(lbl_1.Location);
points.Add(lbl_5.Location);
points.Add(lbl_3.Location);
points.Add(lbl_4.Location);
points.Add(lbl_2.Location);
points.Add(lbl_3.Location);
SizeF sf = g.MeasureString(lbl_1.Text,this.Font);
for (int i=0;i<points.Count;i++)
{
points[i] = new PointF(points[i].X + sf.Width / 2, points[i].Y + sf.Height / 2);
}
Pen pen = new Pen(Color.Red);
pen.DashStyle = System.Drawing.Drawing2D.DashStyle.Dash;
g.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.AntiAlias;
g.DrawLines(pen, points.ToArray());
g.DrawLine(pen,
new PointF(lbl_4.Location.X + sf.Width / 2, lbl_4.Location.Y + sf.Height / 2),
new PointF(lbl_5.Location.X + sf.Width / 2, lbl_5.Location.Y + sf.Height / 2));
pen.Dispose();
}
--------------------编程问答-------------------- 楼上正解,用GDI绘图 --------------------编程问答--------------------
大神,我只想知道object sender, PaintEventArgs e这些参数是嘛意思,在什么情况下写
我自己写的时候就直接一对括号,不知道该往里面写什么 --------------------编程问答--------------------
和数学一样的,函数 y=f(x) --------------------编程问答-------------------- 这个你用WPF更好。
winform画的线,界面稍有风吹草动就没了,还要处理重绘很是麻烦。 --------------------编程问答--------------------
和数学一样的,函数 y=f(x)
我就是需要参数的时候写需要的参数,不需要参数的时候就直接
void a(),不知道为什么好多都有那个sender 和 e
网上说是系统的什么的
但是看别人程序,自己写的也有 --------------------编程问答-------------------- 自己定义的方法当然可以有参,也可无参,看需要而定。VOID A(STRING AA),不知道的可以学啊。
补充:.NET技术 , C#