GraphicsPath.AddLines Method (Point[])


The .NET API Reference documentation has a new home. Visit the .NET API Browser on to see the new experience.

Appends a series of connected line segments to the end of this GraphicsPath.

Namespace:   System.Drawing.Drawing2D
Assembly:  System.Drawing (in System.Drawing.dll)

public void AddLines(
	Point[] points


Type: System.Drawing.Point[]

An array of Point structures that represents the points that define the line segments to add.

If there are previous lines or curves in the figure, a line is added to connect the endpoint of the previous segment the starting point of the line. The points parameter specifies an array of endpoints. The first two specify the first line. Each additional point specifies the endpoint of a line segment whose starting point is the endpoint of the previous line.

The following code example is designed for use with Windows Forms, and it requires PaintEventArgse, an OnPaint event object. The code performs the following actions:

  • Creates an array of four points that describe a triangle.

  • Creates a path and adds the array of lines.

  • Draws the path to screen.

Notice that each line after the first point uses the previous point as the starting point and the new point as the endpoint.

private void AddLinesExample(PaintEventArgs e)

    // Create a symetrical triangle using an array of points.
    Point[] myArray =
                 new Point(30,30),
                 new Point(60,60),
                 new Point(0,60),
                 new Point(30,30)

    //Create a path and add lines.
    GraphicsPath myPath = new GraphicsPath();

    // Draw the path to the screen.
    Pen myPen = new Pen(Color.Black, 2);
    e.Graphics.DrawPath(myPen, myPath);

.NET Framework
Available since 1.1
Return to top