GraphicsPath.AddRectangle Méthode

Définition

Ajoute un rectangle à ce tracé.Adds a rectangle to this path.

Surcharges

AddRectangle(Rectangle)

Ajoute un rectangle à ce tracé.Adds a rectangle to this path.

AddRectangle(RectangleF)

Ajoute un rectangle à ce tracé.Adds a rectangle to this path.

AddRectangle(Rectangle)

Ajoute un rectangle à ce tracé.Adds a rectangle to this path.

public:
 void AddRectangle(System::Drawing::Rectangle rect);
public void AddRectangle (System.Drawing.Rectangle rect);
member this.AddRectangle : System.Drawing.Rectangle -> unit
Public Sub AddRectangle (rect As Rectangle)

Paramètres

rect
Rectangle

Rectangle qui représente le rectangle à ajouter.A Rectangle that represents the rectangle to add.

Exemples

L’exemple de code suivant est conçu pour être utilisé avec Windows Forms, et il requiert PaintEventArgse, un objet d’événement OnPaint.The following code example is designed for use with Windows Forms, and it requires PaintEventArgse, an OnPaint event object. Le code effectue les actions suivantes :The code performs the following actions:

  • Crée un chemin d’accès.Creates a path.

  • Crée un rectangle et ajoute le rectangle au tracé.Creates a rectangle and adds the rectangle to the path.

  • Dessine le tracé à l’écran.Draws the path to the screen.

private:
   void AddRectangleExample( PaintEventArgs^ e )
   {
      // Create a GraphicsPath object and add a rectangle to it.
      GraphicsPath^ myPath = gcnew GraphicsPath;
      Rectangle pathRect = Rectangle(20,20,100,200);
      myPath->AddRectangle( pathRect );

      // Draw the path to the screen.
      Pen^ myPen = gcnew Pen( Color::Black,2.0f );
      e->Graphics->DrawPath( myPen, myPath );
   }
private void AddRectangleExample(PaintEventArgs e)
{
             
    // Create a GraphicsPath object and add a rectangle to it.
    GraphicsPath myPath = new GraphicsPath();
    Rectangle pathRect = new Rectangle(20, 20, 100, 200);
    myPath.AddRectangle(pathRect);
             
    // Draw the path to the screen.
    Pen myPen = new Pen(Color.Black, 2);
    e.Graphics.DrawPath(myPen, myPath);
}
Public Sub AddRectangleExample(ByVal e As PaintEventArgs)

    ' Create a GraphicsPath object and add a rectangle to it.
    Dim myPath As New GraphicsPath
    Dim pathRect As New Rectangle(20, 20, 100, 200)
    myPath.AddRectangle(pathRect)

    ' Draw the path to the screen.
    Dim myPen As New Pen(Color.Black, 2)
    e.Graphics.DrawPath(myPen, myPath)
End Sub

AddRectangle(RectangleF)

Ajoute un rectangle à ce tracé.Adds a rectangle to this path.

public:
 void AddRectangle(System::Drawing::RectangleF rect);
public void AddRectangle (System.Drawing.RectangleF rect);
member this.AddRectangle : System.Drawing.RectangleF -> unit
Public Sub AddRectangle (rect As RectangleF)

Paramètres

rect
RectangleF

RectangleF qui représente le rectangle à ajouter.A RectangleF that represents the rectangle to add.

Exemples

Pour obtenir un exemple, consultez AddRectangle(Rectangle).For an example, see AddRectangle(Rectangle).

S’applique à