Graphics.DrawLines Method

Definition

Draws a series of line segments that connect an array of Point structures.

Overloads

DrawLines(Pen, ReadOnlySpan<Point>)

Draws a series of line segments that connect an array of Point structures.

DrawLines(Pen, ReadOnlySpan<PointF>)

Draws a series of line segments that connect an array of Point structures.

DrawLines(Pen, Point[])

Draws a series of line segments that connect an array of Point structures.

DrawLines(Pen, PointF[])

Draws a series of line segments that connect an array of PointF structures.

DrawLines(Pen, ReadOnlySpan<Point>)

Source:
Graphics.cs

Draws a series of line segments that connect an array of Point structures.

public:
 void DrawLines(System::Drawing::Pen ^ pen, ReadOnlySpan<System::Drawing::Point> points);
public void DrawLines (System.Drawing.Pen pen, scoped ReadOnlySpan<System.Drawing.Point> points);
member this.DrawLines : System.Drawing.Pen * ReadOnlySpan<System.Drawing.Point> -> unit
Public Sub DrawLines (pen As Pen, points As ReadOnlySpan(Of Point))

Parameters

pen
Pen

Pen that determines the color, width, and style of the line segments.

points
ReadOnlySpan<Point>

Array of Point structures that represent the points to connect.

Applies to

DrawLines(Pen, ReadOnlySpan<PointF>)

Source:
Graphics.cs

Draws a series of line segments that connect an array of Point structures.

public:
 void DrawLines(System::Drawing::Pen ^ pen, ReadOnlySpan<System::Drawing::PointF> points);
public void DrawLines (System.Drawing.Pen pen, scoped ReadOnlySpan<System.Drawing.PointF> points);
member this.DrawLines : System.Drawing.Pen * ReadOnlySpan<System.Drawing.PointF> -> unit
Public Sub DrawLines (pen As Pen, points As ReadOnlySpan(Of PointF))

Parameters

pen
Pen

Pen that determines the color, width, and style of the line segments.

points
ReadOnlySpan<PointF>

Array of Point structures that represent the points to connect.

Applies to

DrawLines(Pen, Point[])

Source:
Graphics.cs
Source:
Graphics.cs

Draws a series of line segments that connect an array of Point structures.

public:
 void DrawLines(System::Drawing::Pen ^ pen, cli::array <System::Drawing::Point> ^ points);
public:
 void DrawLines(System::Drawing::Pen ^ pen, ... cli::array <System::Drawing::Point> ^ points);
public void DrawLines (System.Drawing.Pen pen, System.Drawing.Point[] points);
public void DrawLines (System.Drawing.Pen pen, params System.Drawing.Point[] points);
member this.DrawLines : System.Drawing.Pen * System.Drawing.Point[] -> unit
Public Sub DrawLines (pen As Pen, points As Point())
Public Sub DrawLines (pen As Pen, ParamArray points As Point())

Parameters

pen
Pen

Pen that determines the color, width, and style of the line segments.

points
Point[]

Array of Point structures that represent the points to connect.

Exceptions

pen is null.

-or-

points is null.

Examples

The following code example is designed for use with Windows Forms, and it requires PaintEventArgs e, which is a parameter of the Paint event handler. The code performs the following actions:

  • Creates a black pen.

  • Creates an array of points of segments of the line.

  • Draws the connected line segments to the screen.

public:
   void DrawLinesPoint( PaintEventArgs^ e )
   {
      // Create pen.
      Pen^ pen = gcnew Pen( Color::Black,3.0f );

      // Create array of points that define lines to draw.
      array<Point>^ points = {Point(10,10),Point(10,100),Point(200,50),Point(250,300)};

      //Draw lines to screen.
      e->Graphics->DrawLines( pen, points );
   }
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);
}
Public Sub DrawLinesPoint(ByVal e As PaintEventArgs)

    ' Create pen.
    Dim blackPen As New Pen(Color.Black, 3)

    ' Create array of points that define lines to draw.
    Dim points As Point() = {New Point(10, 10), New Point(10, 100), _
    New Point(200, 50), New Point(250, 300)}

    'Draw lines to screen.
    e.Graphics.DrawLines(blackPen, points)
End Sub

Remarks

This method draws a series of lines connecting an array of ending points. The first two points in the array specify the first line. Each additional point specifies the end of a line segment whose starting point is the ending point of the previous line segment.

Applies to

DrawLines(Pen, PointF[])

Source:
Graphics.cs
Source:
Graphics.cs

Draws a series of line segments that connect an array of PointF structures.

public:
 void DrawLines(System::Drawing::Pen ^ pen, cli::array <System::Drawing::PointF> ^ points);
public:
 void DrawLines(System::Drawing::Pen ^ pen, ... cli::array <System::Drawing::PointF> ^ points);
public void DrawLines (System.Drawing.Pen pen, System.Drawing.PointF[] points);
public void DrawLines (System.Drawing.Pen pen, params System.Drawing.PointF[] points);
member this.DrawLines : System.Drawing.Pen * System.Drawing.PointF[] -> unit
Public Sub DrawLines (pen As Pen, points As PointF())
Public Sub DrawLines (pen As Pen, ParamArray points As PointF())

Parameters

pen
Pen

Pen that determines the color, width, and style of the line segments.

points
PointF[]

Array of PointF structures that represent the points to connect.

Exceptions

pen is null.

-or-

points is null.

Examples

The following code example is designed for use with Windows Forms, and it requires PaintEventArgs e, which is a parameter of the Paint event handler. The code performs the following actions:

  • Code creates a black pen.

  • Creates an array of points of segments of the line.

  • Draws the connected line segments to the screen.

public:
   void DrawLinesPointF( PaintEventArgs^ e )
   {
      // Create pen.
      Pen^ pen = gcnew Pen( Color::Black,3.0f );

      // Create array of points that define lines to draw.
      array<PointF>^ points = {PointF(10.0F,10.0F),PointF(10.0F,100.0F),PointF(200.0F,50.0F),PointF(250.0F,300.0F)};

      //Draw lines to screen.
      e->Graphics->DrawLines( pen, points );
   }
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);
}
Public Sub DrawLinesPointF(ByVal e As PaintEventArgs)

    ' Create pen.
    Dim blackPen As New Pen(Color.Black, 3)

    ' Create array of points that define lines to draw.
    Dim points As PointF() = {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(blackPen, points)
End Sub

Remarks

This method draws a series of lines connecting an array of ending points. The first two points in the array specify the first line. Each additional point specifies the end of a line segment whose starting point is the ending point of the previous line segment.

Applies to