Files
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

1.7 KiB

title, ms.date, dev_langs, helpviewer_keywords, ms.assetid
title ms.date dev_langs helpviewer_keywords ms.assetid
How to: Use Clipping with a Region 03/30/2017
csharp
vb
regions [Windows Forms], clipping
regions [Windows Forms], restricting drawing surface
43d121b4-e14c-4901-b25c-2d6c25ba4e29

How to: Use Clipping with a Region

One of the properties of the xref:System.Drawing.Graphics class is the clip region. All drawing done by a given xref:System.Drawing.Graphics object is restricted to the clip region of that xref:System.Drawing.Graphics object. You can set the clip region by calling the xref:System.Drawing.Graphics.SetClip%2A method.

Example

The following example constructs a path that consists of a single polygon. Then the code constructs a region, based on that path. The region is passed to the xref:System.Drawing.Graphics.SetClip%2A method of a xref:System.Drawing.Graphics object, and then two strings are drawn.

The following illustration shows the clipped strings:

Screenshot that shows clipped strings.

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

Compiling the Code

The preceding example is designed for use with Windows Forms, and it requires xref:System.Windows.Forms.PaintEventArgs e, which is a parameter of xref:System.Windows.Forms.PaintEventHandler.

See also