Rectangle.FromLTRB(Int32, Int32, Int32, Int32) Method

Definition

Creates a Rectangle structure with the specified edge locations.

C#
public static System.Drawing.Rectangle FromLTRB(int left, int top, int right, int bottom);

Parameters

left
Int32

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

top
Int32

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

right
Int32

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

bottom
Int32

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

Returns

The new Rectangle that this method creates.

Examples

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.

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

Remarks

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

Applies to

Product Versions
.NET Core 1.0, Core 1.1, Core 2.0, Core 2.1, Core 2.2, Core 3.0, Core 3.1, 5, 6, 7, 8, 9
.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, 2.1