更新 : 2007 年 11 月
以下のコード例は、フォーム上で塗りつぶされた楕円を描画する方法を示しています。
使用例
System.Drawing.SolidBrush brush1 =
new System.Drawing.SolidBrush(System.Drawing.Color.Red);
System.Drawing.Graphics formGraphics = this.CreateGraphics();
formGraphics.FillEllipse(brush1, new System.Drawing.Rectangle(0,0,200,300));
brush1.Dispose();
formGraphics.Dispose();
コードのコンパイル方法
この例には、次の項目が必要です。
- formGraphics という名前のフォームのある Windows フォーム アプリケーション プロジェクト。
コードは form クラスのスコープ内にある必要があります。フォームのインスタンスは this として表されます。
堅牢性の高いプログラム
システム リソースを消費するオブジェクト (Brush オブジェクトや Graphics オブジェクトなど) では、必ず Dispose を呼び出す必要があります。
参照
概念
ユーザー インターフェイスのデザイン (Visual C#)