Graphics.DrawRectangle Metodo
Importante
Alcune informazioni sono relative alla release non definitiva del prodotto, che potrebbe subire modifiche significative prima della release definitiva. Microsoft non riconosce alcuna garanzia, espressa o implicita, in merito alle informazioni qui fornite.
Disegna un rettangolo specificato da una coppia di coordinate, una larghezza e un'altezza.
DrawRectangle(Pen, Int32, Int32, Int32, Int32) |
Disegna un rettangolo specificato da una coppia di coordinate, una larghezza e un'altezza. |
DrawRectangle(Pen, Single, Single, Single, Single) |
Disegna un rettangolo specificato da una coppia di coordinate, una larghezza e un'altezza. |
DrawRectangle(Pen, RectangleF) |
Disegna il contorno del rettangolo specificato. |
DrawRectangle(Pen, Rectangle) |
Disegna un rettangolo specificato da una struttura Rectangle. |
- Origine:
- Graphics.cs
- Origine:
- Graphics.cs
- Origine:
- Graphics.cs
- Origine:
- Graphics.cs
- Origine:
- Graphics.cs
- Origine:
- Graphics.cs
Disegna un rettangolo specificato da una coppia di coordinate, una larghezza e un'altezza.
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)
Parametri
- x
- Int32
Coordinata x dell'angolo superiore sinistro del rettangolo da disegnare.
- y
- Int32
Coordinata y dell'angolo superiore sinistro del rettangolo da disegnare.
- width
- Int32
Larghezza del rettangolo da disegnare.
- height
- Int32
Altezza del rettangolo da disegnare.
Eccezioni
pen
è null
.
Esempio
L'esempio di codice seguente è progettato per l'uso con Windows Form e richiede PaintEventArgse
, che è un parametro del gestore eventi Paint. Il codice esegue le azioni seguenti:
Crea una penna nera.
Crea la posizione e le dimensioni di un rettangolo.
Disegna il rettangolo sullo schermo.
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
Commenti
Per informazioni su come disegnare un RectangleF, vedere DrawRectangles(Pen, RectangleF[]).
Si applica a
.NET 10 (package-provided) e altre versioni
Prodotto | Versioni |
---|---|
.NET | 8 (package-provided), 9 (package-provided), 10 (package-provided) |
.NET Framework | 1.1, 2.0, 3.0, 3.5, 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1 |
.NET Standard | 2.0 (package-provided) |
Windows Desktop | 3.0, 3.1, 5, 6, 7, 8, 9, 10 |
- Origine:
- Graphics.cs
- Origine:
- Graphics.cs
- Origine:
- Graphics.cs
- Origine:
- Graphics.cs
- Origine:
- Graphics.cs
- Origine:
- Graphics.cs
Disegna un rettangolo specificato da una coppia di coordinate, una larghezza e un'altezza.
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)
Parametri
- x
- Single
Coordinata x dell'angolo superiore sinistro del rettangolo da disegnare.
- y
- Single
Coordinata y dell'angolo superiore sinistro del rettangolo da disegnare.
- width
- Single
Larghezza del rettangolo da disegnare.
- height
- Single
Altezza del rettangolo da disegnare.
Eccezioni
pen
è null
.
Esempio
L'esempio di codice seguente è progettato per l'uso con Windows Form e richiede PaintEventArgse
, che è un parametro del gestore eventi Paint. Il codice esegue le azioni seguenti:
Crea una penna nera.
Crea la posizione e le dimensioni di un rettangolo.
Disegna il rettangolo sullo schermo.
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
Commenti
Per informazioni su come disegnare un RectangleF, vedere DrawRectangles(Pen, RectangleF[]).
Si applica a
.NET 10 (package-provided) e altre versioni
Prodotto | Versioni |
---|---|
.NET | 8 (package-provided), 9 (package-provided), 10 (package-provided) |
.NET Framework | 1.1, 2.0, 3.0, 3.5, 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1 |
.NET Standard | 2.0 (package-provided) |
Windows Desktop | 3.0, 3.1, 5, 6, 7, 8, 9, 10 |
- Origine:
- Graphics.cs
- Origine:
- Graphics.cs
- Origine:
- Graphics.cs
- Origine:
- Graphics.cs
- Origine:
- Graphics.cs
- Origine:
- Graphics.cs
Disegna il contorno del rettangolo specificato.
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)
Parametri
- pen
- Pen
Penna che determina il colore, la larghezza e lo stile del rettangolo.
- rect
- RectangleF
Rettangolo da disegnare.
Si applica a
.NET 10 (package-provided) e altre versioni
Prodotto | Versioni |
---|---|
.NET | 8 (package-provided), 9 (package-provided), 10 (package-provided) |
Windows Desktop | 7, 8, 9, 10 |
- Origine:
- Graphics.cs
- Origine:
- Graphics.cs
- Origine:
- Graphics.cs
- Origine:
- Graphics.cs
- Origine:
- Graphics.cs
- Origine:
- Graphics.cs
Disegna un rettangolo specificato da una struttura 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)
Parametri
Eccezioni
pen
è null
.
Esempio
L'esempio di codice seguente è progettato per l'uso con Windows Form e richiede PaintEventArgse
, che è un parametro del gestore eventi Paint. Il codice esegue le azioni seguenti:
Crea una penna nera.
Crea un rettangolo.
Disegna il rettangolo sullo schermo.
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
Commenti
Per informazioni su come disegnare un RectangleF, vedere DrawRectangles(Pen, RectangleF[]).
Si applica a
.NET 10 (package-provided) e altre versioni
Prodotto | Versioni |
---|---|
.NET | 8 (package-provided), 9 (package-provided), 10 (package-provided) |
.NET Framework | 1.1, 2.0, 3.0, 3.5, 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1 |
.NET Standard | 2.0 (package-provided) |
Windows Desktop | 3.0, 3.1, 5, 6, 7, 8, 9, 10 |
Feedback su .NET
.NET è un progetto di open source. Selezionare un collegamento per fornire feedback: