共用方式為


Graphics.DrawEllipse 方法

定義

繪製由一對座標、高度和寬度所指定的周框所定義的橢圓形。

多載

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

繪製由矩形左上角座標所指定的周框所定義的橢圓形、高度和寬度。

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

繪製由一對座標、高度和寬度所指定的周框所定義的橢圓形。

DrawEllipse(Pen, RectangleF)

繪製由周框 RectangleF定義的省略號。

DrawEllipse(Pen, Rectangle)

繪製由周框 Rectangle 結構指定的省略號。

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

來源:
Graphics.cs
來源:
Graphics.cs

繪製由矩形左上角座標所指定的周框所定義的橢圓形、高度和寬度。

public:
 void DrawEllipse(System::Drawing::Pen ^ pen, int x, int y, int width, int height);
public void DrawEllipse (System.Drawing.Pen pen, int x, int y, int width, int height);
member this.DrawEllipse : System.Drawing.Pen * int * int * int * int -> unit
Public Sub DrawEllipse (pen As Pen, x As Integer, y As Integer, width As Integer, height As Integer)

參數

pen
Pen

Pen,決定橢圓形的色彩、寬度和樣式。

x
Int32

定義橢圓形之周框左上角的 X 座標。

y
Int32

定義橢圓形之周框左上角的 Y 座標。

width
Int32

定義橢圓形的周框寬度。

height
Int32

定義橢圓形的周框高度。

例外狀況

pen null

範例

下列程式代碼範例是專為搭配 Windows Forms 使用而設計,而且需要 PaintEventArgse,這是 Paint 事件處理程式的參數。 程式代碼會執行下列動作:

  • 建立黑色畫筆。

  • 建立矩形的位置和大小,以系結橢圓形。

  • 將省略號繪製到螢幕。

private:
   void DrawEllipseInt( PaintEventArgs^ e )
   {
      // Create pen.
      Pen^ blackPen = gcnew Pen( Color::Black,3.0f );

      // 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 );
   }
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);
}
Private Sub DrawEllipseInt(ByVal e As PaintEventArgs)

    ' Create pen.
    Dim blackPen As New Pen(Color.Black, 3)

    ' Create location and size of ellipse.
    Dim x As Integer = 0
    Dim y As Integer = 0
    Dim width As Integer = 200
    Dim height As Integer = 100

    ' Draw ellipse to screen.
    e.Graphics.DrawEllipse(blackPen, x, y, width, height)
End Sub

備註

這個方法會繪製由 xywidthheight 參數所描述的周框所定義的橢圓形。

適用於

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

來源:
Graphics.cs
來源:
Graphics.cs

繪製由一對座標、高度和寬度所指定的周框所定義的橢圓形。

public:
 void DrawEllipse(System::Drawing::Pen ^ pen, float x, float y, float width, float height);
public void DrawEllipse (System.Drawing.Pen pen, float x, float y, float width, float height);
member this.DrawEllipse : System.Drawing.Pen * single * single * single * single -> unit
Public Sub DrawEllipse (pen As Pen, x As Single, y As Single, width As Single, height As Single)

參數

pen
Pen

Pen,決定橢圓形的色彩、寬度和樣式。

x
Single

定義橢圓形之周框左上角的 X 座標。

y
Single

定義橢圓形之周框左上角的 Y 座標。

width
Single

定義橢圓形的周框寬度。

height
Single

定義橢圓形的周框高度。

例外狀況

pen null

範例

下列程式代碼範例是專為搭配 Windows Forms 使用而設計,而且需要 PaintEventArgse,這是 Paint 事件處理程式的參數。 程式代碼會執行下列動作:

  • 建立黑色畫筆。

  • 建立矩形的位置和大小,以系結橢圓形。

  • 將省略號繪製到螢幕。

private:
   void DrawEllipseFloat( PaintEventArgs^ e )
   {
      // Create pen.
      Pen^ blackPen = gcnew Pen( Color::Black,3.0f );

      // 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 );
   }
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);
}
Private Sub DrawEllipseFloat(ByVal e As PaintEventArgs)

    ' Create pen.
    Dim blackPen As New Pen(Color.Black, 3)

    ' Create location and size of ellipse.
    Dim x As Single = 0.0F
    Dim y As Single = 0.0F
    Dim width As Single = 200.0F
    Dim height As Single = 100.0F

    ' Draw ellipse to screen.
    e.Graphics.DrawEllipse(blackPen, x, y, width, height)
End Sub

備註

這個方法會繪製由 xywidthheight 參數所描述的周框所定義的橢圓形。

適用於

DrawEllipse(Pen, RectangleF)

來源:
Graphics.cs
來源:
Graphics.cs

繪製由周框 RectangleF定義的省略號。

public:
 void DrawEllipse(System::Drawing::Pen ^ pen, System::Drawing::RectangleF rect);
public void DrawEllipse (System.Drawing.Pen pen, System.Drawing.RectangleF rect);
member this.DrawEllipse : System.Drawing.Pen * System.Drawing.RectangleF -> unit
Public Sub DrawEllipse (pen As Pen, rect As RectangleF)

參數

pen
Pen

Pen,決定橢圓形的色彩、寬度和樣式。

rect
RectangleF

RectangleF 結構,定義橢圓形的界限。

例外狀況

pen null

範例

下列程式代碼範例是專為搭配 Windows Forms 使用而設計,而且需要 PaintEventArgse,這是 Paint 事件處理程式的參數。 程式代碼會執行下列動作:

  • 建立黑色畫筆。

  • 建立矩形來系結橢圓形。

  • 將省略號繪製到螢幕。

private:
   void DrawEllipseRectangleF( PaintEventArgs^ e )
   {
      // Create pen.
      Pen^ blackPen = gcnew Pen( Color::Black,3.0f );

      // Create rectangle for ellipse.
      RectangleF rect = RectangleF(0.0F,0.0F,200.0F,100.0F);

      // Draw ellipse to screen.
      e->Graphics->DrawEllipse( blackPen, rect );
   }
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);
}
Private Sub DrawEllipseRectangleF(ByVal e As PaintEventArgs)

    ' Create pen.
    Dim blackPen As New Pen(Color.Black, 3)

    ' Create rectangle for ellipse.
    Dim rect As New RectangleF(0.0F, 0.0F, 200.0F, 100.0F)

    ' Draw ellipse to screen.
    e.Graphics.DrawEllipse(blackPen, rect)
End Sub

備註

這個方法會繪製由 rect 參數所指定的周框所定義的橢圓形。

適用於

DrawEllipse(Pen, Rectangle)

來源:
Graphics.cs
來源:
Graphics.cs

繪製由周框 Rectangle 結構指定的省略號。

public:
 void DrawEllipse(System::Drawing::Pen ^ pen, System::Drawing::Rectangle rect);
public void DrawEllipse (System.Drawing.Pen pen, System.Drawing.Rectangle rect);
member this.DrawEllipse : System.Drawing.Pen * System.Drawing.Rectangle -> unit
Public Sub DrawEllipse (pen As Pen, rect As Rectangle)

參數

pen
Pen

Pen,決定橢圓形的色彩、寬度和樣式。

rect
Rectangle

Rectangle 結構,定義橢圓形的界限。

例外狀況

pen null

範例

下列程式代碼範例是專為搭配 Windows Forms 使用而設計,而且需要 PaintEventArgse,這是 Paint 事件處理程式的參數。 程式代碼會執行下列動作:

  • 建立黑色畫筆。

  • 建立矩形來系結橢圓形。

  • 將省略號繪製到螢幕。

private:
   void DrawEllipseRectangle( PaintEventArgs^ e )
   {
      // Create pen.
      Pen^ blackPen = gcnew Pen( Color::Black,3.0f );

      // Create rectangle for ellipse.
      Rectangle rect = Rectangle(0,0,200,100);

      // Draw ellipse to screen.
      e->Graphics->DrawEllipse( blackPen, rect );
   }
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);
}
Private Sub DrawEllipseRectangle(ByVal e As PaintEventArgs)

    ' Create pen.
    Dim blackPen As New Pen(Color.Black, 3)

    ' Create rectangle for ellipse.
    Dim rect As New Rectangle(0, 0, 200, 100)

    ' Draw ellipse to screen.
    e.Graphics.DrawEllipse(blackPen, rect)
End Sub

備註

這個方法會繪製由 rect 參數所指定的周框所定義的橢圓形。

適用於