如何从两点画一条线?

时间:2016-12-11 13:50:13

标签: c# winforms

如何在Windows窗体应用程序中使用System.Draw从2个圆圈中绘制一条线?

2 个答案:

答案 0 :(得分:0)

使用Graphics.DrawLine,例如:

public void DrawLinePoint(PaintEventArgs e)
{
    // Create pen.
    Pen blackPen = new Pen(Color.Black, 3);

    // Create points that define line.   
    Point point1 = new Point(100, 100);   
    Point point2 = new Point(500, 100);   

    // Draw line to screen.   
    e.Graphics.DrawLine(blackPen, point1, point2);   
}

有关详细信息,请参阅MSDN:https://msdn.microsoft.com/en-us/library/f956fzw1(v=vs.110).aspx

答案 1 :(得分:0)

只需使用Graphics.DrawLine()方法。

查看Documentation