Graphics.DrawRectangle 메서드
정의
중요
일부 정보는 릴리스되기 전에 상당 부분 수정될 수 있는 시험판 제품과 관련이 있습니다. Microsoft는 여기에 제공된 정보에 대해 어떠한 명시적이거나 묵시적인 보증도 하지 않습니다.
좌표 쌍, 너비 및 높이로 지정된 사각형을 그립니다.
오버로드
| DrawRectangle(Pen, Int32, Int32, Int32, Int32) |
좌표 쌍, 너비 및 높이로 지정된 사각형을 그립니다. |
| DrawRectangle(Pen, Single, Single, Single, Single) |
좌표 쌍, 너비 및 높이로 지정된 사각형을 그립니다. |
| DrawRectangle(Pen, RectangleF) |
지정된 사각형의 윤곽선을 그립니다. |
| DrawRectangle(Pen, Rectangle) |
Rectangle 구조체로 지정된 사각형을 그립니다. |
DrawRectangle(Pen, Int32, Int32, Int32, Int32)
- Source:
- Graphics.cs
- Source:
- Graphics.cs
- Source:
- Graphics.cs
- Source:
- Graphics.cs
- Source:
- Graphics.cs
- Source:
- Graphics.cs
좌표 쌍, 너비 및 높이로 지정된 사각형을 그립니다.
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
Public Sub DrawRectangle (pen As Pen, x As Integer, y As Integer, width As Integer, height As Integer)
매개 변수
- x
- Int32
그릴 사각형의 왼쪽 위 모퉁이에 대한 x 좌표입니다.
- y
- Int32
그릴 사각형의 왼쪽 위 모퉁이의 y 좌표입니다.
- width
- Int32
그릴 사각형의 너비입니다.
- height
- Int32
그릴 사각형의 높이입니다.
예외
pen
null.
예제
다음 코드 예제는 Windows Forms에서 사용하도록 설계되었으며 Paint 이벤트 처리기의 매개 변수인 PaintEventArgse필요합니다. 코드는 다음 작업을 수행합니다.
검은색 펜을 만듭니다.
사각형의 위치와 크기를 만듭니다.
화면에 사각형을 그립니다.
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[])참조하세요.
적용 대상
DrawRectangle(Pen, Single, Single, Single, Single)
- Source:
- Graphics.cs
- Source:
- Graphics.cs
- Source:
- Graphics.cs
- Source:
- Graphics.cs
- Source:
- Graphics.cs
- Source:
- Graphics.cs
좌표 쌍, 너비 및 높이로 지정된 사각형을 그립니다.
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
Public Sub DrawRectangle (pen As Pen, x As Single, y As Single, width As Single, height As Single)
매개 변수
- x
- Single
그릴 사각형의 왼쪽 위 모퉁이에 대한 x 좌표입니다.
- y
- Single
그릴 사각형의 왼쪽 위 모퉁이의 y 좌표입니다.
- width
- Single
그릴 사각형의 너비입니다.
- height
- Single
그릴 사각형의 높이입니다.
예외
pen
null.
예제
다음 코드 예제는 Windows Forms에서 사용하도록 설계되었으며 Paint 이벤트 처리기의 매개 변수인 PaintEventArgse필요합니다. 코드는 다음 작업을 수행합니다.
검은색 펜을 만듭니다.
사각형의 위치와 크기를 만듭니다.
화면에 사각형을 그립니다.
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[])참조하세요.
적용 대상
DrawRectangle(Pen, RectangleF)
- Source:
- Graphics.cs
- Source:
- Graphics.cs
- Source:
- Graphics.cs
- Source:
- Graphics.cs
- Source:
- Graphics.cs
- Source:
- Graphics.cs
지정된 사각형의 윤곽선을 그립니다.
public:
void DrawRectangle(System::Drawing::Pen ^ pen, System::Drawing::RectangleF rect);
public void DrawRectangle(System.Drawing.Pen pen, System.Drawing.RectangleF rect);
member this.DrawRectangle : System.Drawing.Pen * System.Drawing.RectangleF -> unit
Public Sub DrawRectangle (pen As Pen, rect As RectangleF)
매개 변수
- pen
- Pen
사각형의 색, 너비 및 스타일을 결정하는 펜입니다.
- rect
- RectangleF
그릴 사각형입니다.
적용 대상
DrawRectangle(Pen, Rectangle)
- Source:
- Graphics.cs
- Source:
- Graphics.cs
- Source:
- Graphics.cs
- Source:
- Graphics.cs
- Source:
- Graphics.cs
- Source:
- Graphics.cs
Rectangle 구조체로 지정된 사각형을 그립니다.
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
Public Sub DrawRectangle (pen As Pen, rect As Rectangle)
매개 변수
예외
pen
null.
예제
다음 코드 예제는 Windows Forms에서 사용하도록 설계되었으며 Paint 이벤트 처리기의 매개 변수인 PaintEventArgse필요합니다. 코드는 다음 작업을 수행합니다.
검은색 펜을 만듭니다.
사각형을 만듭니다.
화면에 사각형을 그립니다.
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[])참조하세요.