Graphics.DrawLines 方法

定義

繪製一系列的線段,以連接 Point 結構的陣列。

多載

DrawLines(Pen, ReadOnlySpan<Point>)
DrawLines(Pen, ReadOnlySpan<PointF>)
DrawLines(Pen, Point[])

繪製一系列的線段,以連接 Point 結構的陣列。

DrawLines(Pen, PointF[])

繪製一系列的線段,以連接 PointF 結構的陣列。

DrawLines(Pen, ReadOnlySpan<Point>)

來源:
Graphics.cs
來源:
Graphics.cs
C#
public void DrawLines (System.Drawing.Pen pen, scoped ReadOnlySpan<System.Drawing.Point> points);

參數

pen
Pen

適用於

.NET 9 和 Windows Desktop 9
產品 版本
.NET 9
Windows Desktop 9

DrawLines(Pen, ReadOnlySpan<PointF>)

來源:
Graphics.cs
來源:
Graphics.cs
C#
public void DrawLines (System.Drawing.Pen pen, scoped ReadOnlySpan<System.Drawing.PointF> points);

參數

pen
Pen

適用於

.NET 9 和 Windows Desktop 9
產品 版本
.NET 9
Windows Desktop 9

DrawLines(Pen, Point[])

來源:
Graphics.cs
來源:
Graphics.cs
來源:
Graphics.cs
來源:
Graphics.cs
來源:
Graphics.cs

繪製一系列的線段,以連接 Point 結構的陣列。

C#
public void DrawLines (System.Drawing.Pen pen, System.Drawing.Point[] points);
C#
public void DrawLines (System.Drawing.Pen pen, params System.Drawing.Point[] points);

參數

pen
Pen

Pen,決定線條線段的色彩、寬度和樣式。

points
Point[]

Point 結構陣列,表示要連接的點。

例外狀況

pen null

-或-

points null

範例

下列程式代碼範例是專為搭配 Windows Forms 使用而設計,而且需要 PaintEventArgse,這是 Paint 事件處理程式的參數。 程式代碼會執行下列動作:

  • 建立黑色畫筆。

  • 建立線條區段點的陣列。

  • 將連接的線條區段繪製到畫面。

C#
public void DrawLinesPoint(PaintEventArgs e)
{
             
    // Create pen.
    Pen pen = new Pen(Color.Black, 3);
             
    // Create array of points that define lines to draw.
    Point[] points =
             {
                 new Point(10,  10),
                 new Point(10, 100),
                 new Point(200,  50),
                 new Point(250, 300)
             };
             
    //Draw lines to screen.
    e.Graphics.DrawLines(pen, points);
}

備註

這個方法會繪製一系列連接結束點數位的線條。 陣列中的前兩個點會指定第一行。 每個額外的點都會指定線段的終點,其起點是上一行線段的終點。

適用於

.NET 9 和其他版本
產品 版本
.NET 6, 7, 8, 9
.NET Framework 1.1, 2.0, 3.0, 3.5, 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1
.NET Standard 2.0
Windows Desktop 3.0, 3.1, 5, 6, 7, 8, 9

DrawLines(Pen, PointF[])

來源:
Graphics.cs
來源:
Graphics.cs
來源:
Graphics.cs
來源:
Graphics.cs
來源:
Graphics.cs

繪製一系列的線段,以連接 PointF 結構的陣列。

C#
public void DrawLines (System.Drawing.Pen pen, System.Drawing.PointF[] points);
C#
public void DrawLines (System.Drawing.Pen pen, params System.Drawing.PointF[] points);

參數

pen
Pen

Pen,決定線條線段的色彩、寬度和樣式。

points
PointF[]

PointF 結構陣列,表示要連接的點。

例外狀況

pen null

-或-

points null

範例

下列程式代碼範例是專為搭配 Windows Forms 使用而設計,而且需要 PaintEventArgse,這是 Paint 事件處理程式的參數。 程式代碼會執行下列動作:

  • 程序代碼會建立黑色畫筆。

  • 建立線條區段點的陣列。

  • 將連接的線條區段繪製到畫面。

C#
public void DrawLinesPointF(PaintEventArgs e)
{
             
    // Create pen.
    Pen pen = new Pen(Color.Black, 3);
             
    // Create array of points that define lines to draw.
    PointF[] points =
             {
                 new PointF(10.0F,  10.0F),
                 new PointF(10.0F, 100.0F),
                 new PointF(200.0F,  50.0F),
                 new PointF(250.0F, 300.0F)
             };
             
    //Draw lines to screen.
    e.Graphics.DrawLines(pen, points);
}

備註

這個方法會繪製一系列連接結束點數位的線條。 陣列中的前兩個點會指定第一行。 每個額外的點都會指定線段的終點,其起點是上一行線段的終點。

適用於

.NET 9 和其他版本
產品 版本
.NET 6, 7, 8, 9
.NET Framework 1.1, 2.0, 3.0, 3.5, 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1
.NET Standard 2.0
Windows Desktop 3.0, 3.1, 5, 6, 7, 8, 9