Fills the inside of a rectangle.
Syntax

[C#]

void FillRectangle(Brush brush, double x, double y, double width, double height);
void FillRectangle(Brush brush, RectangleF rect);

[Visual Basic]

Sub FillRectangle(brush As Brush, x As Double, y As Double, width As Double, height As Double)
Sub FillRectangle(brush As Brush, rect As RectangleF)
Params
Name Description
brush The brush to use for the fill.
x x coordinate of the top-left corner of the rectangle.
y y coordinate of the top-left corner of the rectangle.
width Width of the rectangle.
height Height of the rectangle.
rect The rectangle to be filled.
Notes

None.

Example

Here we paint a blue rectangle on the Bitmap.

[C#]

using (Bitmap bm = new Bitmap(500, 500)) {
  using (Graphics gr = Graphics.FromImage(bm))
    gr.FillRectangle(Brushes.Blue, new RectangleF(50, 50, 400, 400));
  bm.Save(Server.MapPath("IG8_Graphics_FillRectangle.png"));
}



IG8_Graphics_FillRectangle.png