共用方式為


Graphics.FillRegion(Brush, Region) 方法

定義

填滿 Region的內部。

public:
 void FillRegion(System::Drawing::Brush ^ brush, System::Drawing::Region ^ region);
public void FillRegion (System.Drawing.Brush brush, System.Drawing.Region region);
member this.FillRegion : System.Drawing.Brush * System.Drawing.Region -> unit
Public Sub FillRegion (brush As Brush, region As Region)

參數

brush
Brush

決定填滿特性的 Brush

region
Region

Region,代表要填滿的區域。

例外狀況

brush null

-或-

region null

範例

下列程式代碼範例是專為搭配 Windows Forms 使用而設計,而且需要 PaintEventArgse,這是 Paint 事件處理程式的參數。 程式代碼會執行下列動作:

  • 建立純藍色筆刷。

  • 建立矩形。

  • 建立矩形區域。

  • 填滿螢幕上的矩形區域。

public:
   void FillRegionRectangle( PaintEventArgs^ e )
   {
      // Create solid brush.
      SolidBrush^ blueBrush = gcnew SolidBrush( Color::Blue );

      // Create rectangle for region.
      Rectangle fillRect = Rectangle(100,100,200,200);

      // Create region for fill.
      System::Drawing::Region^ fillRegion = gcnew System::Drawing::Region( fillRect );

      // Fill region to screen.
      e->Graphics->FillRegion( blueBrush, fillRegion );
   }
private 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);
}
Private Sub FillRegionRectangle(ByVal 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

備註

Region 是由矩形和路徑所組成。 如果區域未關閉,則會將額外的區段從最後一個點新增至第一個點以關閉它。

適用於