GraphicsPath.ClearMarkers Method ()


Clears all markers from this path.

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

public void ClearMarkers()

Use the SetMarkers method to create a marker at the current location in a GraphicsPath. Use the NextMarker method to iterate through the existing markers in a path.

Markers are used to separate groups of subpaths. One or more subpaths can be contained between two markers.

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 a path.

  • Adds several objects to the path.

  • Adds markers to the path.

  • Clears all markers from the path.

  • Draws the path to the screen.

private void ClearMarkersExample(PaintEventArgs e)

    // Set several markers in a path.
    GraphicsPath myPath = new GraphicsPath();
    myPath.AddEllipse(0, 0, 100, 200);
    myPath.AddLine(new Point(100, 100), new Point(200, 100));
    Rectangle rect = new Rectangle(200, 0, 100, 200);
    myPath.AddLine(new Point(250, 200), new Point(250, 300));

    // Clear the markers.

    // 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