This documentation is archived and is not being maintained.

Graphics.FillRectangles Method

Fills the interiors of a series of rectangles specified by Rectangle structures.

Overload List

Fills the interiors of a series of rectangles specified by Rectangle structures.

[Visual Basic] Overloads Public Sub FillRectangles(Brush, Rectangle())
[C#] public void FillRectangles(Brush, Rectangle[]);
[C++] public: void FillRectangles(Brush*, Rectangle[]);
[JScript] public function FillRectangles(Brush, Rectangle[]);

Fills the interiors of a series of rectangles specified by RectangleF structures.

[Visual Basic] Overloads Public Sub FillRectangles(Brush, RectangleF())
[C#] public void FillRectangles(Brush, RectangleF[]);
[C++] public: void FillRectangles(Brush*, RectangleF[]);
[JScript] public function FillRectangles(Brush, RectangleF[]);

Example

[Visual Basic, C#] The following example is designed for use with Windows Forms, and it requires PaintEventArgs e, which is a parameter of the Paint event handler. The code performs the following action:

  • Creates a solid blue brush.
  • Creates an array of three rectangles.
  • Fills the three rectangular areas on the screen.
[Visual Basic, C#] Note   This example shows how to use one of the overloaded versions of FillRectangles. For other examples that might be available, see the individual overload topics.
[Visual Basic] 
Public Sub FillRectanglesRectangleF(e As PaintEventArgs)
' Create solid brush.
Dim blueBrush As New SolidBrush(Color.Blue)
' Create array of rectangles.
Dim rects As RectangleF() =  {New RectangleF(0F, 0F, 100F, 200F), _
New RectangleF(100F, 200F, 250F, 50F), _
New RectangleF(300F, 0F, 50F, 100F)}
' Fill rectangles to screen.
e.Graphics.FillRectangles(blueBrush, rects)
End Sub
        
[C#] 
public void FillRectanglesRectangleF(PaintEventArgs e)
{
// Create solid brush.
SolidBrush blueBrush = new SolidBrush(Color.Blue);
// Create array of rectangles.
RectangleF[] rects =
{
new RectangleF(  0.0F,   0.0F, 100.0F, 200.0F),
new RectangleF(100.0F, 200.0F, 250.0F,  50.0F),
new RectangleF(300.0F,   0.0F,  50.0F, 100.0F)
};
// Fill rectangles to screen.
e.Graphics.FillRectangles(blueBrush, rects);
}
        

[C++, JScript] No example is available for C++ or JScript. To view a Visual Basic or C# example, click the Language Filter button Language Filter in the upper-left corner of the page.

See Also

Graphics Class | Graphics Members | System.Drawing Namespace

Show: