Graphics.DrawRectangle Metódus
Definíció
Fontos
Egyes információk olyan, kiadás előtti termékekre vonatkoznak, amelyek a kiadásig még jelentősen módosulhatnak. A Microsoft nem vállal kifejezett vagy törvényi garanciát az itt megjelenő információért.
Egy koordinátapár, szélesség és magasság által megadott téglalapot rajzol.
Túlterhelések
| Name | Description |
|---|---|
| DrawRectangle(Pen, Int32, Int32, Int32, Int32) |
Egy koordinátapár, szélesség és magasság által megadott téglalapot rajzol. |
| DrawRectangle(Pen, Single, Single, Single, Single) |
Egy koordinátapár, szélesség és magasság által megadott téglalapot rajzol. |
| DrawRectangle(Pen, RectangleF) |
A megadott téglalap körvonalát rajzolja meg. |
| DrawRectangle(Pen, Rectangle) |
Egy struktúra által Rectangle megadott téglalapot rajzol. |
DrawRectangle(Pen, Int32, Int32, Int32, Int32)
- Forrás:
- Graphics.cs
- Forrás:
- Graphics.cs
- Forrás:
- Graphics.cs
- Forrás:
- Graphics.cs
- Forrás:
- Graphics.cs
- Forrás:
- Graphics.cs
- Forrás:
- Graphics.cs
- Forrás:
- Graphics.cs
Egy koordinátapár, szélesség és magasság által megadott téglalapot rajzol.
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)
Paraméterek
- x
- Int32
A rajzolni kívánt téglalap bal felső sarkának x koordinátája.
- y
- Int32
A rajzolni kívánt téglalap bal felső sarkának y koordinátája.
- width
- Int32
A rajzolni kívánt téglalap szélessége.
- height
- Int32
A rajzolni kívánt téglalap magassága.
Kivételek
pen az null.
Példák
Az alábbi kódpéldát Windows Forms való használatra tervezték, és PaintEventArgse, amely a Paint eseménykezelő paramétere. A kód a következő műveleteket hajtja végre:
Fekete tollat hoz létre.
Egy téglalap pozícióját és méretét hozza létre.
A téglalapot a képernyőre rajzolja.
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
Megjegyzések
A rajzolás RectangleFmódjáról további információt a következő témakörben talál DrawRectangles(Pen, RectangleF[]):
A következőre érvényes:
DrawRectangle(Pen, Single, Single, Single, Single)
- Forrás:
- Graphics.cs
- Forrás:
- Graphics.cs
- Forrás:
- Graphics.cs
- Forrás:
- Graphics.cs
- Forrás:
- Graphics.cs
- Forrás:
- Graphics.cs
- Forrás:
- Graphics.cs
- Forrás:
- Graphics.cs
Egy koordinátapár, szélesség és magasság által megadott téglalapot rajzol.
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)
Paraméterek
- x
- Single
A rajzolni kívánt téglalap bal felső sarkának x koordinátája.
- y
- Single
A rajzolni kívánt téglalap bal felső sarkának y koordinátája.
- width
- Single
A rajzolni kívánt téglalap szélessége.
- height
- Single
A rajzolni kívánt téglalap magassága.
Kivételek
pen az null.
Példák
Az alábbi kódpéldát Windows Forms való használatra tervezték, és PaintEventArgse, amely a Paint eseménykezelő paramétere. A kód a következő műveleteket hajtja végre:
Fekete tollat hoz létre.
Egy téglalap pozícióját és méretét hozza létre.
A téglalapot a képernyőre rajzolja.
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
Megjegyzések
A rajzolás RectangleFmódjáról további információt a következő témakörben talál DrawRectangles(Pen, RectangleF[]):
A következőre érvényes:
DrawRectangle(Pen, RectangleF)
- Forrás:
- Graphics.cs
- Forrás:
- Graphics.cs
- Forrás:
- Graphics.cs
- Forrás:
- Graphics.cs
- Forrás:
- Graphics.cs
- Forrás:
- Graphics.cs
- Forrás:
- Graphics.cs
- Forrás:
- Graphics.cs
A megadott téglalap körvonalát rajzolja meg.
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)
Paraméterek
- pen
- Pen
A téglalap színét, szélességét és stílusát meghatározó toll.
- rect
- RectangleF
A rajzolni kívánt téglalap.
A következőre érvényes:
DrawRectangle(Pen, Rectangle)
- Forrás:
- Graphics.cs
- Forrás:
- Graphics.cs
- Forrás:
- Graphics.cs
- Forrás:
- Graphics.cs
- Forrás:
- Graphics.cs
- Forrás:
- Graphics.cs
- Forrás:
- Graphics.cs
- Forrás:
- Graphics.cs
Egy struktúra által Rectangle megadott téglalapot rajzol.
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)
Paraméterek
Kivételek
pen az null.
Példák
Az alábbi kódpéldát Windows Forms való használatra tervezték, és PaintEventArgse, amely a Paint eseménykezelő paramétere. A kód a következő műveleteket hajtja végre:
Fekete tollat hoz létre.
Téglalapot hoz létre.
A téglalapot a képernyőre rajzolja.
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
Megjegyzések
A rajzolás RectangleFmódjáról további információt a következő témakörben talál DrawRectangles(Pen, RectangleF[]):