Files
docs-desktop/dotnet-desktop-guide/framework/winforms/advanced/how-to-fill-a-shape-with-a-hatch-pattern.md
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.3 KiB

title, ms.date, dev_langs, helpviewer_keywords, ms.assetid
title ms.date dev_langs helpviewer_keywords ms.assetid
How to: Fill a Shape with a Hatch Pattern 03/30/2017
csharp
vb
patterns [Windows Forms], adding to shapes
shapes [Windows Forms], filling with patterns
brushes [Windows Forms], using hatch brushes
9c8300ff-187b-404f-af1f-ebd499f5b16f

How to: Fill a Shape with a Hatch Pattern

A hatch pattern is made from two colors: one for the background and one for the lines that form the pattern over the background. To fill a closed shape with a hatch pattern, use a xref:System.Drawing.Drawing2D.HatchBrush object. The following example demonstrates how to fill an ellipse with a hatch pattern:

Example

The xref:System.Drawing.Drawing2D.HatchBrush.%23ctor%2A constructor takes three arguments: the hatch style, the color of the hatch line, and the color of the background. The hatch style argument can be any value from the xref:System.Drawing.Drawing2D.HatchStyle enumeration. There are more than fifty elements in the xref:System.Drawing.Drawing2D.HatchStyle enumeration; a few of those elements are shown in the following list:

The following illustration shows the filled ellipse.

Screenshot of what an ellipse filled with a hatch pattern looks like.

[!code-csharpSystem.Drawing.UsingABrush#41] [!code-vbSystem.Drawing.UsingABrush#41]

Compiling the Code

The preceding example is designed for use with Windows Forms, and it requires xref:System.Windows.Forms.PaintEventArgse, which is a parameter of the xref:System.Windows.Forms.Control.Paint event handler.

See also