Export (0) Print
Expand All

Rectangle.FromLTRB Method

Creates a Rectangle structure with the specified edge locations.

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

public static Rectangle FromLTRB(
	int left,
	int top,
	int right,
	int bottom
)

Parameters

left
Type: System.Int32

The x-coordinate of the upper-left corner of this Rectangle structure.

top
Type: System.Int32

The y-coordinate of the upper-left corner of this Rectangle structure.

right
Type: System.Int32

The x-coordinate of the lower-right corner of this Rectangle structure.

bottom
Type: System.Int32

The y-coordinate of the lower-right corner of this Rectangle structure.

Return Value

Type: System.Drawing.Rectangle
The new Rectangle that this method creates.

This method creates a Rectangle with the specified upper-left and lower-right corners.

The following code example demonstrates how to create a rectangle using the FromLTRB method. This example is designed to be used with a Windows Form. Paste this code into a form and call the CreateARectangleFromLTRB method when handling the form's Paint event, passing e as PaintEventArgs.

private void CreateARectangleFromLTRB(PaintEventArgs e)
{
    Rectangle myRectangle = Rectangle.FromLTRB(40, 40, 140, 240);
    e.Graphics.DrawRectangle(SystemPens.ControlText, myRectangle);
}

.NET Framework

Supported in: 4.5.2, 4.5.1, 4.5, 4, 3.5, 3.0, 2.0, 1.1, 1.0

.NET Framework Client Profile

Supported in: 4, 3.5 SP1

Windows 8.1, Windows Server 2012 R2, Windows 8, Windows Server 2012, Windows 7, Windows Vista SP2, Windows Server 2008 (Server Core Role not supported), Windows Server 2008 R2 (Server Core Role supported with SP1 or later; Itanium not supported)

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

Show:
© 2014 Microsoft