Rectangle.Inflate Method (Int32, Int32) (System.Drawing)

Switch View :
ScriptFree
.NET Framework Class Library
Rectangle.Inflate Method (Int32, Int32)

Enlarges this Rectangle by the specified amount.

Namespace:  System.Drawing
Assembly:  System.Drawing (in System.Drawing.dll)
Syntax

Visual Basic
Public Sub Inflate ( _
	width As Integer, _
	height As Integer _
)
C#
public void Inflate(
	int width,
	int height
)
Visual C++
public:
void Inflate(
	int width, 
	int height
)
F#
member Inflate : 
        width:int * 
        height:int -> unit 

Parameters

width
Type: System.Int32
The amount to inflate this Rectangle horizontally.
height
Type: System.Int32
The amount to inflate this Rectangle vertically.
Remarks

This method enlarges this rectangle, not a copy of it. The rectangle is enlarged in both directions along an axis. For example, if a 50 by 50 rectangle is enlarged by 50 in the x-axis, the resultant rectangle will be 150 units long (the original 50, the 50 in the minus direction, and the 50 in the plus direction) maintaining the rectangle's geometric center.

If either x or y is negative, the Rectangle structure is deflated in the corresponding direction.

Examples

The following example creates a Rectangle structure and enlarges it by 100 units in the x-axis direction:

Visual Basic

Public Sub RectangleInflateTest3(ByVal e As PaintEventArgs)

    ' Create a rectangle.
    Dim rect As New Rectangle(100, 100, 50, 50)

    ' Draw the uninflated rectangle to screen.
    e.Graphics.DrawRectangle(Pens.Black, rect)

    ' Call Inflate.
    rect.Inflate(50, 50)

    ' Draw the inflated rectangle to screen.
    e.Graphics.DrawRectangle(Pens.Red, rect)
End Sub


C#

public void RectangleInflateTest3(PaintEventArgs e)
{

    // Create a rectangle.
    Rectangle rect = new Rectangle(100, 100, 50, 50);

    // Draw the uninflated rectangle to screen.
    e.Graphics.DrawRectangle(Pens.Black, rect);

    // Call Inflate.
    rect.Inflate(50, 50);

    // Draw the inflated rectangle to screen.
    e.Graphics.DrawRectangle(Pens.Red, rect);
}


Visual C++

public:
   void RectangleInflateTest3( PaintEventArgs^ e )
   {
      // Create a rectangle.
      Rectangle rect = Rectangle(100,100,50,50);

      // Draw the uninflated rectangle to screen.
      e->Graphics->DrawRectangle( Pens::Black, rect );

      // Call Inflate.
      rect.Inflate( 50, 50 );

      // Draw the inflated rectangle to screen.
      e->Graphics->DrawRectangle( Pens::Red, rect );
   }


Version Information

.NET Framework

Supported in: 4, 3.5, 3.0, 2.0, 1.1, 1.0

.NET Framework Client Profile

Supported in: 4, 3.5 SP1
Platforms

Windows 7, Windows Vista SP1 or later, Windows XP SP3, Windows XP SP2 x64 Edition, Windows Server 2008 (Server Core not supported), Windows Server 2008 R2 (Server Core supported with SP1 or later), Windows Server 2003 SP2

The .NET Framework does not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.
See Also

Reference