Fills the interior of a rectangle specified by a pair of coordinates, a width, and a height.
Overload List
Fills the interior of a rectangle specified by a Rectangle structure.
Supported by the .NET Compact Framework.
[Visual Basic] Overloads Public Sub FillRectangle(Brush, Rectangle)
[C#] public void FillRectangle(Brush, Rectangle);
[C++] public: void FillRectangle(Brush*, Rectangle);
[JScript] public function FillRectangle(Brush, Rectangle);
Fills the interior of a rectangle specified by a RectangleF structure.
[Visual Basic] Overloads Public Sub FillRectangle(Brush, RectangleF)
[C#] public void FillRectangle(Brush, RectangleF);
[C++] public: void FillRectangle(Brush*, RectangleF);
[JScript] public function FillRectangle(Brush, RectangleF);
Fills the interior of a rectangle specified by a pair of coordinates, a width, and a height.
Supported by the .NET Compact Framework.
[Visual Basic] Overloads Public Sub FillRectangle(Brush, Integer, Integer, Integer, Integer)
[C#] public void FillRectangle(Brush, int, int, int, int);
[C++] public: void FillRectangle(Brush*, int, int, int, int);
[JScript] public function FillRectangle(Brush, int, int, int, int);
Fills the interior of a rectangle specified by a pair of coordinates, a width, and a height.
[Visual Basic] Overloads Public Sub FillRectangle(Brush, Single, Single, Single, Single)
[C#] public void FillRectangle(Brush, float, float, float, float);
[C++] public: void FillRectangle(Brush*, float, float, float, float);
[JScript] public function FillRectangle(Brush, float, float, float, float);
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 the location and size of a rectangle.
- Fills the rectangular area on the screen.
[Visual Basic, C#] Note This example shows how to use one of the overloaded versions of FillRectangle. For other examples that might be available, see the individual overload topics.
[Visual Basic]
Public Sub FillRectangleFloat(e As PaintEventArgs)
' Create solid brush.
Dim blueBrush As New SolidBrush(Color.Blue)
' Create location and size of rectangle.
Dim x As Single = 0F
Dim y As Single = 0F
Dim width As Single = 200F
Dim height As Single = 200F
' Fill rectangle to screen.
e.Graphics.FillRectangle(blueBrush, x, y, width, height)
End Sub
[C#]
public void FillRectangleFloat(PaintEventArgs e)
{
// Create solid brush.
SolidBrush blueBrush = new SolidBrush(Color.Blue);
// Create location and size of rectangle.
float x = 0.0F;
float y = 0.0F;
float width = 200.0F;
float height = 200.0F;
// Fill rectangle to screen.
e.Graphics.FillRectangle(blueBrush, x, y, width, height);
}
[C++, JScript] No example is available for C++ or JScript. To view a Visual Basic or C# example, click the Language Filter button
in the upper-left corner of the page.
See Also
Graphics Class | Graphics Members | System.Drawing Namespace