Export (0) Print
Expand All

GraphicsPath.CloseFigure Method

Closes the current figure and starts a new figure. If the current figure contains a sequence of connected lines and curves, the method closes the loop by connecting a line from the endpoint to the starting point.

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

public void CloseFigure()

The following code example is designed for use with Windows Forms, and it requires PaintEventArgs e, an OnPaint event object. The code creates a triangle by creating a new path, starting a figure, adding two intersecting lines to the figure, and then closing the figure to form a triangle. The path is then drawn to the screen.

private void CloseFigureExample(PaintEventArgs e)

    // Create a path consisting of two, open-ended lines and close 

    // the lines using CloseFigure.
    GraphicsPath myPath = new GraphicsPath();
    myPath.AddLine(new Point(10, 10), new Point(200, 10));
    myPath.AddLine(new Point(200, 10), new Point(200, 200));

    // Draw the path to the screen.
    e.Graphics.DrawPath(Pens.Black, myPath);

.NET Framework

Supported in: 4.5.2, 4.5.1, 4.5, 4, 3.5, 3.0, 2.0, 1.1, 1.0

.NET Framework Client Profile

Supported in: 4, 3.5 SP1

Windows 8.1, Windows Server 2012 R2, Windows 8, Windows Server 2012, Windows 7, Windows Vista SP2, Windows Server 2008 (Server Core Role not supported), Windows Server 2008 R2 (Server Core Role supported with SP1 or later; Itanium not supported)

The .NET Framework does not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.

© 2014 Microsoft