Graphics.DrawEllipse Method

Definition

Draws an ellipse defined by a bounding rectangle specified by a pair of coordinates, a height, and a width.

Overloads

DrawEllipse(Pen, Int32, Int32, Int32, Int32)

Draws an ellipse defined by a bounding rectangle specified by coordinates for the upper-left corner of the rectangle, a height, and a width.

DrawEllipse(Pen, Single, Single, Single, Single)

Draws an ellipse defined by a bounding rectangle specified by a pair of coordinates, a height, and a width.

DrawEllipse(Pen, RectangleF)

Draws an ellipse defined by a bounding RectangleF.

DrawEllipse(Pen, Rectangle)

Draws an ellipse specified by a bounding Rectangle structure.

DrawEllipse(Pen, Int32, Int32, Int32, Int32)

Source:
Graphics.cs
Source:
Graphics.cs
Source:
Graphics.cs
Source:
Graphics.cs
Source:
Graphics.cs
Source:
Graphics.cs

Draws an ellipse defined by a bounding rectangle specified by coordinates for the upper-left corner of the rectangle, a height, and a width.

C#
public void DrawEllipse(System.Drawing.Pen pen, int x, int y, int width, int height);

Parameters

pen
Pen

Pen that determines the color, width, and style of the ellipse.

x
Int32

The x-coordinate of the upper-left corner of the bounding rectangle that defines the ellipse.

y
Int32

The y-coordinate of the upper-left corner of the bounding rectangle that defines the ellipse.

width
Int32

Width of the bounding rectangle that defines the ellipse.

height
Int32

Height of the bounding rectangle that defines the ellipse.

Exceptions

pen 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 the position and size of a rectangle to bound an ellipse.

  • Draws the ellipse to the screen.

C#
private void DrawEllipseInt(PaintEventArgs e)
{
    // Create pen.
    Pen blackPen = new Pen(Color.Black, 3);
             
    // Create location and size of ellipse.
    int x = 0;
    int y = 0;
    int width = 200;
    int height = 100;
             
    // Draw ellipse to screen.
    e.Graphics.DrawEllipse(blackPen, x, y, width, height);
}

Remarks

This method draws an ellipse that is defined by the bounding rectangle described by the x, y, width, and height parameters.

Applies to

.NET 9 (package-provided) and other versions
Product Versions
.NET 8 (package-provided), 9 (package-provided)
.NET Framework 1.1, 2.0, 3.0, 3.5, 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7 (package-provided), 4.7, 4.7.1 (package-provided), 4.7.1, 4.7.2 (package-provided), 4.7.2, 4.8 (package-provided), 4.8, 4.8.1
.NET Standard 2.0 (package-provided)
Windows Desktop 3.0, 3.1, 5, 6, 7, 8, 9

DrawEllipse(Pen, Single, Single, Single, Single)

Source:
Graphics.cs
Source:
Graphics.cs
Source:
Graphics.cs
Source:
Graphics.cs
Source:
Graphics.cs
Source:
Graphics.cs

Draws an ellipse defined by a bounding rectangle specified by a pair of coordinates, a height, and a width.

C#
public void DrawEllipse(System.Drawing.Pen pen, float x, float y, float width, float height);

Parameters

pen
Pen

Pen that determines the color, width, and style of the ellipse.

x
Single

The x-coordinate of the upper-left corner of the bounding rectangle that defines the ellipse.

y
Single

The y-coordinate of the upper-left corner of the bounding rectangle that defines the ellipse.

width
Single

Width of the bounding rectangle that defines the ellipse.

height
Single

Height of the bounding rectangle that defines the ellipse.

Exceptions

pen 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 the position and size of a rectangle to bound an ellipse.

  • Draws the ellipse to the screen.

C#
private void DrawEllipseFloat(PaintEventArgs e)
{         
    // Create pen.
    Pen blackPen = new Pen(Color.Black, 3);
             
    // Create location and size of ellipse.
    float x = 0.0F;
    float y = 0.0F;
    float width = 200.0F;
    float height = 100.0F;
             
    // Draw ellipse to screen.
    e.Graphics.DrawEllipse(blackPen, x, y, width, height);
}

Remarks

This method draws an ellipse that is defined by the bounding rectangle described by the x, y, width, and height parameters.

Applies to

.NET 9 (package-provided) and other versions
Product Versions
.NET 8 (package-provided), 9 (package-provided)
.NET Framework 1.1, 2.0, 3.0, 3.5, 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7 (package-provided), 4.7, 4.7.1 (package-provided), 4.7.1, 4.7.2 (package-provided), 4.7.2, 4.8 (package-provided), 4.8, 4.8.1
.NET Standard 2.0 (package-provided)
Windows Desktop 3.0, 3.1, 5, 6, 7, 8, 9

DrawEllipse(Pen, RectangleF)

Source:
Graphics.cs
Source:
Graphics.cs
Source:
Graphics.cs
Source:
Graphics.cs
Source:
Graphics.cs
Source:
Graphics.cs

Draws an ellipse defined by a bounding RectangleF.

C#
public void DrawEllipse(System.Drawing.Pen pen, System.Drawing.RectangleF rect);

Parameters

pen
Pen

Pen that determines the color, width, and style of the ellipse.

rect
RectangleF

RectangleF structure that defines the boundaries of the ellipse.

Exceptions

pen 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 a rectangle to bound an ellipse.

  • Draws the ellipse to the screen.

C#
private void DrawEllipseRectangleF(PaintEventArgs e)
{
    // Create pen.
    Pen blackPen = new Pen(Color.Black, 3);
             
    // Create rectangle for ellipse.
    RectangleF rect = new RectangleF(0.0F, 0.0F, 200.0F, 100.0F);
             
    // Draw ellipse to screen.
    e.Graphics.DrawEllipse(blackPen, rect);
}

Remarks

This method draws an ellipse that is defined by the bounding rectangle specified by the rect parameter.

Applies to

.NET 9 (package-provided) and other versions
Product Versions
.NET 8 (package-provided), 9 (package-provided)
.NET Framework 1.1, 2.0, 3.0, 3.5, 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7 (package-provided), 4.7, 4.7.1 (package-provided), 4.7.1, 4.7.2 (package-provided), 4.7.2, 4.8 (package-provided), 4.8, 4.8.1
.NET Standard 2.0 (package-provided)
Windows Desktop 3.0, 3.1, 5, 6, 7, 8, 9

DrawEllipse(Pen, Rectangle)

Source:
Graphics.cs
Source:
Graphics.cs
Source:
Graphics.cs
Source:
Graphics.cs
Source:
Graphics.cs
Source:
Graphics.cs

Draws an ellipse specified by a bounding Rectangle structure.

C#
public void DrawEllipse(System.Drawing.Pen pen, System.Drawing.Rectangle rect);

Parameters

pen
Pen

Pen that determines the color, width, and style of the ellipse.

rect
Rectangle

Rectangle structure that defines the boundaries of the ellipse.

Exceptions

pen 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 a rectangle to bound an ellipse.

  • Draws the ellipse to the screen.

C#
private void DrawEllipseRectangle(PaintEventArgs e)
{
    // Create pen.
    Pen blackPen = new Pen(Color.Black, 3);
             
    // Create rectangle for ellipse.
    Rectangle rect = new Rectangle(0, 0, 200, 100);
             
    // Draw ellipse to screen.
    e.Graphics.DrawEllipse(blackPen, rect);
}

Remarks

This method draws an ellipse that is defined by the bounding rectangle specified by the rect parameter.

Applies to

.NET 9 (package-provided) and other versions
Product Versions
.NET 8 (package-provided), 9 (package-provided)
.NET Framework 1.1, 2.0, 3.0, 3.5, 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7 (package-provided), 4.7, 4.7.1 (package-provided), 4.7.1, 4.7.2 (package-provided), 4.7.2, 4.8 (package-provided), 4.8, 4.8.1
.NET Standard 2.0 (package-provided)
Windows Desktop 3.0, 3.1, 5, 6, 7, 8, 9