GraphicsPath.AddRectangle メソッド

定義

パスに四角形を追加します。Adds a rectangle to this path.

オーバーロード

AddRectangle(Rectangle)

パスに四角形を追加します。Adds a rectangle to this path.

AddRectangle(RectangleF)

パスに四角形を追加します。Adds a rectangle to this path.

AddRectangle(Rectangle)

パスに四角形を追加します。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)

パラメーター

rect
Rectangle

追加する四角形を表す RectangleA Rectangle that represents the rectangle to add.

次のコード例は、Windows フォームで使用するように設計されており、イベントオブジェクトを必要とし PaintEventArgs e OnPaint ます。The following code example is designed for use with Windows Forms, and it requires PaintEventArgse, an OnPaint event object. コードは、次のアクションを実行します。The code performs the following actions:

  • パスを作成します。Creates a path.

  • 四角形を作成し、そのパスに四角形を追加します。Creates a rectangle and adds the rectangle to the path.

  • 画面へのパスを描画します。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)

パスに四角形を追加します。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)

パラメーター

rect
RectangleF

追加する四角形を表す RectangleFA RectangleF that represents the rectangle to add.

例については、「AddRectangle(Rectangle)」を参照してください。For an example, see AddRectangle(Rectangle).

適用対象