Export (0) Print
Expand All
This topic has not yet been rated - Rate this topic

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.StartFigure();
    myPath.AddLine(new Point(10, 10), new Point(200, 10));
    myPath.AddLine(new Point(200, 10), new Point(200, 200));
    myPath.CloseFigure();

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

Windows 7, Windows Vista, Windows XP SP2, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP Starter Edition, Windows Server 2008 R2, Windows Server 2008, Windows Server 2003, Windows Server 2000 SP4, Windows Millennium Edition, Windows 98

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

.NET Framework

Supported in: 3.5, 3.0, 2.0, 1.1, 1.0
Did you find this helpful?
(1500 characters remaining)
Thank you for your feedback

Community Additions

ADD
Show:
© 2014 Microsoft. All rights reserved.