The topic you requested is included in another documentation set. For convenience, it's displayed below. Choose Switch to see the topic in its original location.
How to: Draw a Filled Rectangle on a Windows Form
This example draws a filled rectangle on a form.
System.Drawing.SolidBrush myBrush = new System.Drawing.SolidBrush(System.Drawing.Color.Red);
formGraphics = this.CreateGraphics();
formGraphics.FillRectangle(myBrush, new Rectangle(0, 0, 200, 300));
You cannot call this method in the
event handler. The drawn content will not be redrawn if the form is resized or obscured by another form. To make your content automatically repaint, you should override the Load method. OnPaint
You should always call
on any objects that consume system resources, such as Dispose and Brush objects. Graphics Concepts Reference Other Resources
Did you find this helpful?
( 1500 characters remaining)
Thank you for your feedback