| title | ms.custom | ms.date | ms.prod | ms.reviewer | ms.suite | ms.technology | ms.tgt_pltfrm | ms.topic | dev_langs | helpviewer_keywords | ms.assetid | caps.latest.revision | author | ms.author | manager | ||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
How to: Print a Windows Form |
03/30/2017 |
.net-framework |
|
article |
|
|
c8dff5f8-f56a-4c07-ae31-64643b31f8fc |
9 |
dotnet-bot |
dotnetcontent |
wpickett |
How to: Print a Windows Form
As part of the development process, you typically will want to print a copy of your Windows Form. The following code example shows how to print a copy of the current form by using the xref:System.Drawing.Graphics.CopyFromScreen%2A method.
Example
[!code-csharpSystem.Drawing.Graphics.CopyFromScreen#1] [!code-vbSystem.Drawing.Graphics.CopyFromScreen#1]
Compiling the Code
This is a complete code example that contains a Main method.
Robust Programming
The following conditions may cause an exception:
-
You do not have permission to access the printer.
-
There is no printer installed.
.NET Framework Security
In order to run this code example, you must have permission to access the printer you use with your computer.
See Also
xref:System.Drawing.Printing.PrintDocument
How to: Render Images with GDI+
How to: Print Graphics in Windows Forms