This documentation is archived and is not being maintained.

Graphics.FillRegion Method

Fills the interior of a Region object.

[Visual Basic]
Public Sub FillRegion( _
   ByVal brush As Brush, _
   ByVal region As Region _
)
[C#]
public void FillRegion(
 Brush brush,
 Region region
);
[C++]
public: void FillRegion(
 Brush* brush,
 Region* region
);
[JScript]
public function FillRegion(
   brush : Brush,
 region : Region
);

Parameters

brush
Brush object that determines the characteristics of the fill.
region
Region object that represents the area to fill.

Return Value

This method does not return a value.

Remarks

A Region object is composed of rectangles and paths. If the region is not closed, an additional segment is added from the last point to the first point to close it.

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 a rectangle.
  • Creates a rectangular region.
  • Fills the rectangular region on the screen.
[Visual Basic] 
Public Sub FillRegionRectangle(e As PaintEventArgs)
' Create solid brush.
Dim blueBrush As New SolidBrush(Color.Blue)
' Create rectangle for region.
Dim fillRect As New Rectangle(100, 100, 200, 200)
' Create region for fill.
Dim fillRegion As New [Region](fillRect)
' Fill region to screen.
e.Graphics.FillRegion(blueBrush, fillRegion)
End Sub
        
[C#] 
public void FillRegionRectangle(PaintEventArgs e)
{
// Create solid brush.
SolidBrush blueBrush = new SolidBrush(Color.Blue);
// Create rectangle for region.
Rectangle fillRect = new Rectangle(100, 100, 200, 200);
// Create region for fill.
Region fillRegion = new Region(fillRect);
// Fill region to screen.
e.Graphics.FillRegion(blueBrush, fillRegion);
}
        

[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.

Requirements

Platforms: Windows 98, Windows NT 4.0, Windows Millennium Edition, Windows 2000, Windows XP Home Edition, Windows XP Professional, Windows Server 2003 family, .NET Compact Framework

See Also

Graphics Class | Graphics Members | System.Drawing Namespace

Show: