Printer Friendly Version      Send     
Click to Rate and Give Feedback
MSDN
MSDN Library
.NET Development
Previous Versions
.NET Framework 1.1
.NET Framework
Reference
System.Drawing
Graphics Class
Methods
DrawArc Method
This page is specific to
Microsoft Visual Studio 2003/.NET Framework 1.1

Other versions are also available for the following:
.NET Framework Class Library
Graphics.DrawArc Method

Draws an arc representing a portion of an ellipse specified by a pair of coordinates, a width, and a height.

Overload List

Draws an arc representing a portion of an ellipse specified by a Rectangle structure.

[Visual Basic] Overloads Public Sub DrawArc(Pen, Rectangle, Single, Single)
[C#] public void DrawArc(Pen, Rectangle, float, float);
[C++] public: void DrawArc(Pen*, Rectangle, float, float);
[JScript] public function DrawArc(Pen, Rectangle, float, float);

Draws an arc representing a portion of an ellipse specified by a RectangleF structure.

[Visual Basic] Overloads Public Sub DrawArc(Pen, RectangleF, Single, Single)
[C#] public void DrawArc(Pen, RectangleF, float, float);
[C++] public: void DrawArc(Pen*, RectangleF, float, float);
[JScript] public function DrawArc(Pen, RectangleF, float, float);

Draws an arc representing a portion of an ellipse specified by a pair of coordinates, a width, and a height.

[Visual Basic] Overloads Public Sub DrawArc(Pen, Integer, Integer, Integer, Integer, Integer, Integer)
[C#] public void DrawArc(Pen, int, int, int, int, int, int);
[C++] public: void DrawArc(Pen*, int, int, int, int, int, int);
[JScript] public function DrawArc(Pen, int, int, int, int, int, int);

Draws an arc representing a portion of an ellipse specified by a pair of coordinates, a width, and a height.

[Visual Basic] Overloads Public Sub DrawArc(Pen, Single, Single, Single, Single, Single, Single)
[C#] public void DrawArc(Pen, float, float, float, float, float, float);
[C++] public: void DrawArc(Pen*, float, float, float, float, float, float);
[JScript] public function DrawArc(Pen, float, float, float, float, float, float);

Example

[Visual Basic, C#] The following 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.
  • Defines the start (45 degrees) and sweep (270 degrees) angles.
  • Draws the elliptical arc to the screen.

[Visual Basic, C#] The result is a partial ellipse missing a segment between + and - 45 degrees of the x axis.

[Visual Basic, C#] Note   This example shows how to use one of the overloaded versions of DrawArc. For other examples that might be available, see the individual overload topics.
[Visual Basic] 
Public Sub DrawArcFloat(e As PaintEventArgs)
' Create pen.
Dim blackPen As New Pen(Color.Black, 3)
' Create coordinates of rectangle to bound ellipse.
Dim x As Single = 0F
Dim y As Single = 0F
Dim width As Single = 100F
Dim height As Single = 200F
' Create start and sweep angles on ellipse.
Dim startAngle As Single = 45F
Dim sweepAngle As Single = 270F
' Draw arc to screen.
e.Graphics.DrawArc(blackPen, x, y, width, height, startAngle, _
sweepAngle)
End Sub
        
[C#] 
public void DrawArcFloat(PaintEventArgs e)
{
// Create pen.
Pen blackPen= new Pen(Color.Black, 3);
// Create coordinates of rectangle to bound ellipse.
float x = 0.0F;
float y = 0.0F;
float width = 100.0F;
float height = 200.0F;
// Create start and sweep angles on ellipse.
float startAngle =  45.0F;
float sweepAngle = 270.0F;
// Draw arc to screen.
e.Graphics.DrawArc(blackPen, x, y, width, height, startAngle, sweepAngle);
}
        

[C++, JScript] No example is available for C++ or JScript. To view a Visual Basic or C# example, click the Language Filter button Language Filter in the upper-left corner of the page.

See Also

Graphics Class | Graphics Members | System.Drawing Namespace

© 2008 Microsoft Corporation. All rights reserved. Terms of Use  |  Trademarks  |  Privacy Statement
Page view tracker