共用方式為


HOW TO:建立實心筆刷

這個範例會建立 SolidBrush 物件,Graphics 物件可以使用這個物件來填滿圖案。

範例

Dim myBrush As New System.Drawing.SolidBrush(System.Drawing.Color.Red)
Dim formGraphics As System.Drawing.Graphics
formGraphics = Me.CreateGraphics()
formGraphics.FillEllipse(myBrush, New Rectangle(0, 0, 200, 300))
myBrush.Dispose()
formGraphics.Dispose()
System.Drawing.SolidBrush myBrush = new System.Drawing.SolidBrush(System.Drawing.Color.Red);
System.Drawing.Graphics formGraphics;
formGraphics = this.CreateGraphics();
formGraphics.FillEllipse(myBrush, new Rectangle(0, 0, 200, 300));
myBrush.Dispose();
formGraphics.Dispose();
System::Drawing::SolidBrush^ myBrush =
    gcnew System::Drawing::SolidBrush(System::Drawing::Color::Red);
System::Drawing::Graphics^ formGraphics;
formGraphics = this->CreateGraphics();
formGraphics->FillEllipse(myBrush, Rectangle(0, 0, 200, 300));
delete myBrush;
delete formGraphics;

穩固程式設計

用完物件之後,您應該對任何使用系統資源的物件 (如筆刷物件) 呼叫 Dispose

請參閱

參考

SolidBrush

Brush

概念

GDI+ 中的筆刷和填滿的形狀

其他資源

圖形程式設計入門

使用筆刷填滿形狀