System.Drawing.Rectangle Structure

Stores a set of four integers that represent the location and size of a rectangle

See Also: Rectangle Members

Syntax

[System.ComponentModel.TypeConverter(typeof(System.Drawing.RectangleConverter))]
[System.Runtime.InteropServices.ComVisible(true)]
public struct Rectangle

Remarks

A rectangle is defined by its Rectangle.Width, Rectangle.Height, and upper-left corner represented by the Rectangle.Location property.

To draw rectangles, you need a System.Drawing.Graphics object and a System.Drawing.Pen object. The System.Drawing.Graphics object provides the Graphics.DrawRectangle(Pen, Rectangle) method, and the System.Drawing.Pen object stores features of the line, such as color and width. The units the rectangle is drawn in is determined by the Graphics.PageUnit and Graphics.PageScale properties of the graphics object used for drawing. The default unit is pixels.

To draw a System.Drawing.Rectangle filled with color, you need a System.Drawing.Graphics object and an object derived from System.Drawing.Brush such as System.Drawing.SolidBrush or System.Drawing.Drawing2D.LinearGradientBrush. The System.Drawing.Graphics object provides the Graphics.FillRectangle(Brush, Rectangle) method and the System.Drawing.Brush object provides the color and fill information.

For more advanced shapes, use a System.Drawing.Region object.

Requirements

Namespace: System.Drawing
Assembly: System.Drawing (in System.Drawing.dll)
Assembly Versions: 1.0.3300.0, 1.0.5000.0, 2.0.0.0