Graphics.DrawRectangle Graphics.DrawRectangle Graphics.DrawRectangle Method

정의

좌표 쌍, 너비 및 높이에 의해 지정된 사각형을 그립니다.Draws a rectangle specified by a coordinate pair, a width, and a height.

오버로드

DrawRectangle(Pen, Rectangle) DrawRectangle(Pen, Rectangle) DrawRectangle(Pen, Rectangle)

Rectangle 구조체에 의해 지정된 사각형을 그립니다.Draws a rectangle specified by a Rectangle structure.

DrawRectangle(Pen, Int32, Int32, Int32, Int32) DrawRectangle(Pen, Int32, Int32, Int32, Int32) DrawRectangle(Pen, Int32, Int32, Int32, Int32)

좌표 쌍, 너비 및 높이에 의해 지정된 사각형을 그립니다.Draws a rectangle specified by a coordinate pair, a width, and a height.

DrawRectangle(Pen, Single, Single, Single, Single) DrawRectangle(Pen, Single, Single, Single, Single) DrawRectangle(Pen, Single, Single, Single, Single)

좌표 쌍, 너비 및 높이에 의해 지정된 사각형을 그립니다.Draws a rectangle specified by a coordinate pair, a width, and a height.

DrawRectangle(Pen, Rectangle) DrawRectangle(Pen, Rectangle) DrawRectangle(Pen, Rectangle)

Rectangle 구조체에 의해 지정된 사각형을 그립니다.Draws a rectangle specified by a Rectangle structure.

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

매개 변수

pen
Pen Pen Pen

사각형의 색, 너비 및 스타일을 결정하는 Pen입니다.A Pen that determines the color, width, and style of the rectangle.

rect
Rectangle Rectangle Rectangle

그릴 사각형을 나타내는 Rectangle 구조체입니다.A Rectangle structure that represents the rectangle to draw.

예외

예제

다음 코드 예제는 Windows Forms에서 사용 하도록 설계 되었으며 필요 PaintEventArgs e의 매개 변수는 Paint 이벤트 처리기입니다.The following code example is designed for use with Windows Forms, and it requires PaintEventArgse, which is a parameter of the Paint event handler. 이 코드에서는 다음 작업을 수행합니다.The code performs the following actions:

  • Black 펜을 만듭니다.Creates a black pen.

  • 사각형을 만듭니다.Creates a rectangle.

  • 화면에 사각형을 그립니다.Draws the rectangle to the screen.

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

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

      // Draw rectangle to screen.
      e->Graphics->DrawRectangle( blackPen, rect );
   }
public void DrawRectangleRectangle(PaintEventArgs e)
{
             
    // Create pen.
    Pen blackPen = new Pen(Color.Black, 3);
             
    // Create rectangle.
    Rectangle rect = new Rectangle(0, 0, 200, 200);
             
    // Draw rectangle to screen.
    e.Graphics.DrawRectangle(blackPen, rect);
}
Public Sub DrawRectangleRectangle(ByVal e As PaintEventArgs)

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

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

    ' Draw rectangle to screen.
    e.Graphics.DrawRectangle(blackPen, rect)
End Sub

설명

그리는 방법에 대 한 자세한를 RectangleF를 참조 하세요 DrawRectangles(Pen, RectangleF[])합니다.For information about how to draw a RectangleF, see DrawRectangles(Pen, RectangleF[]).

DrawRectangle(Pen, Int32, Int32, Int32, Int32) DrawRectangle(Pen, Int32, Int32, Int32, Int32) DrawRectangle(Pen, Int32, Int32, Int32, Int32)

좌표 쌍, 너비 및 높이에 의해 지정된 사각형을 그립니다.Draws a rectangle specified by a coordinate pair, a width, and a height.

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

매개 변수

pen
Pen Pen Pen

사각형의 색, 너비 및 스타일을 결정하는 Pen입니다.Pen that determines the color, width, and style of the rectangle.

x
Int32 Int32 Int32

그릴 사각형의 왼쪽 위 모퉁이의 X좌표입니다.The x-coordinate of the upper-left corner of the rectangle to draw.

y
Int32 Int32 Int32

그릴 사각형의 왼쪽 위 모퉁이의 Y좌표입니다.The y-coordinate of the upper-left corner of the rectangle to draw.

width
Int32 Int32 Int32

그릴 사각형의 너비입니다.Width of the rectangle to draw.

height
Int32 Int32 Int32

그릴 사각형의 높이입니다.Height of the rectangle to draw.

예외

예제

다음 코드 예제는 Windows Forms에서 사용 하도록 설계 되었으며 필요 PaintEventArgs e의 매개 변수는 Paint 이벤트 처리기입니다.The following code example is designed for use with Windows Forms, and it requires PaintEventArgse, which is a parameter of the Paint event handler. 이 코드에서는 다음 작업을 수행합니다.The code performs the following actions:

  • Black 펜을 만듭니다.Creates a black pen.

  • 사각형의 크기와 위치를 만듭니다.Creates the position and size of a rectangle.

  • 화면에 사각형을 그립니다.Draws the rectangle to the screen.

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

      // Create location and size of rectangle.
      int x = 0;
      int y = 0;
      int width = 200;
      int height = 200;

      // Draw rectangle to screen.
      e->Graphics->DrawRectangle( blackPen, x, y, width, height );
   }
public void DrawRectangleInt(PaintEventArgs e)
{
             
    // Create pen.
    Pen blackPen = new Pen(Color.Black, 3);
             
    // Create location and size of rectangle.
    int x = 0;
    int y = 0;
    int width = 200;
    int height = 200;
             
    // Draw rectangle to screen.
    e.Graphics.DrawRectangle(blackPen, x, y, width, height);
}
Public Sub DrawRectangleInt(ByVal e As PaintEventArgs)

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

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

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

설명

그리는 방법에 대 한 자세한를 RectangleF를 참조 하세요 DrawRectangles(Pen, RectangleF[])합니다.For information about how to draw a RectangleF, see DrawRectangles(Pen, RectangleF[]).

DrawRectangle(Pen, Single, Single, Single, Single) DrawRectangle(Pen, Single, Single, Single, Single) DrawRectangle(Pen, Single, Single, Single, Single)

좌표 쌍, 너비 및 높이에 의해 지정된 사각형을 그립니다.Draws a rectangle specified by a coordinate pair, a width, and a height.

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

매개 변수

pen
Pen Pen Pen

사각형의 색, 너비 및 스타일을 결정하는 Pen입니다.A Pen that determines the color, width, and style of the rectangle.

x
Single Single Single

그릴 사각형의 왼쪽 위 모퉁이의 X좌표입니다.The x-coordinate of the upper-left corner of the rectangle to draw.

y
Single Single Single

그릴 사각형의 왼쪽 위 모퉁이의 Y좌표입니다.The y-coordinate of the upper-left corner of the rectangle to draw.

width
Single Single Single

그릴 사각형의 너비입니다.The width of the rectangle to draw.

height
Single Single Single

그릴 사각형의 높이입니다.The height of the rectangle to draw.

예외

예제

다음 코드 예제는 Windows Forms에서 사용 하도록 설계 되었으며 필요 PaintEventArgs e의 매개 변수는 Paint 이벤트 처리기입니다.The following code example is designed for use with Windows Forms, and it requires PaintEventArgse, which is a parameter of the Paint event handler. 이 코드에서는 다음 작업을 수행합니다.The code performs the following actions:

  • Black 펜을 만듭니다.Creates a black pen.

  • 사각형의 크기와 위치를 만듭니다.Creates the position and size of a rectangle.

  • 화면에 사각형을 그립니다.Draws the rectangle to the screen.

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

      // Create location and size of rectangle.
      float x = 0.0F;
      float y = 0.0F;
      float width = 200.0F;
      float height = 200.0F;

      // Draw rectangle to screen.
      e->Graphics->DrawRectangle( blackPen, x, y, width, height );
   }
public void DrawRectangleFloat(PaintEventArgs e)
{
             
    // Create pen.
    Pen blackPen = new Pen(Color.Black, 3);
             
    // Create location and size of rectangle.
    float x = 0.0F;
    float y = 0.0F;
    float width = 200.0F;
    float height = 200.0F;
             
    // Draw rectangle to screen.
    e.Graphics.DrawRectangle(blackPen, x, y, width, height);
}
Public Sub DrawRectangleFloat(ByVal e As PaintEventArgs)

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

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

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

설명

그리는 방법에 대 한 자세한를 RectangleF를 참조 하세요 DrawRectangles(Pen, RectangleF[])합니다.For information about how to draw a RectangleF, see DrawRectangles(Pen, RectangleF[]).

적용 대상