Share via


방법: Windows Form에서 채워진 타원 그리기

다음은 양식에 채워진 타원을 그리는 예제입니다.

예제

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;
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();
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()

코드 컴파일

Load 이벤트 처리기에서 이 메서드를 호출할 수 없습니다. 양식의 크기가 조정되거나 다른 양식에 의해 가려진 경우 그려진 콘텐츠는 다시 그려지지 않습니다. 콘텐츠가 자동으로 다시 그려지도록 하려면 OnPaint 메서드를 재정의해야 합니다.

강력한 프로그래밍

시스템 리소스(예: BrushGraphics 개체)를 사용하는 모든 개체에서 항상 Dispose를 호출해야 합니다.

참고 항목