Files
docs-desktop/dotnet-desktop-guide/framework/winforms/advanced/how-to-draw-a-filled-rectangle-on-a-windows-form.md
T
Andy De George c0ba284473 Initial winforms content migrated (#18)
* Merge winforms framework content to working branch (#14)

* Breadcrumb / TOC / Move net5 to net folder (#15)

* change path from net5 to net

* Mess with bread/toc

* Mess with bread/toc

* Mess with bread/toc

* Mess with bread/toc

* Mess with bread/toc

* Mess with bread/toc

* Mess with bread/toc

* Mess with bread/toc

* Mess with bread/toc

* Mess with bread/toc

* Mess with bread/toc

* Mess with bread/toc

* Mess with bread/toc

* Mess with bread/toc

* Add .net 5 winforms placeholder article (#16)

* added some metadata and adjusted net5 placeholder

* corrections

* corrections

* corrections

* Test1

* Swapping landing page vs concept

* fix links

* Fix links

* Fix desc
2020-09-01 16:26:21 -07:00

2.0 KiB

title, description, ms.date, dev_langs, f1_keywords, helpviewer_keywords, ms.assetid
title description ms.date dev_langs f1_keywords helpviewer_keywords ms.assetid
How to: Draw a Filled Rectangle on a Windows Form Learn how to programmatically draw a filled rectangle on a Windows Form. Also learn about compiling your code. 03/30/2017
csharp
vb
cpp
Graphics.FillRectangle
drawing [Windows Forms], rectangles
rectangles [Windows Forms], drawing
drawing rectangles
d656a93c-987d-4809-aafd-493fe17450f0

How to: Draw a Filled Rectangle on a Windows Form

This example draws a filled rectangle on a form.

Example

[!code-cppSystem.Drawing.ConceptualHowTos#2] [!code-csharpSystem.Drawing.ConceptualHowTos#2] [!code-vbSystem.Drawing.ConceptualHowTos#2]

Compiling the Code

You cannot call this method in the xref:System.Windows.Forms.Form.Load 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 xref:System.Windows.Forms.Control.OnPaint%2A method.

Robust Programming

You should always call xref:System.IDisposable.Dispose%2A on any objects that consume system resources, such as xref:System.Drawing.Brush and xref:System.Drawing.Graphics objects.

See also