* 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
2.0 KiB
title, ms.date, dev_langs, helpviewer_keywords, ms.assetid
| title | ms.date | dev_langs | helpviewer_keywords | ms.assetid | |||||||
|---|---|---|---|---|---|---|---|---|---|---|---|
| How to: Capture User Input from a PrintDialog at Run Time | 03/30/2017 |
|
|
438501d8-9a70-4fb3-aae6-e46579aba0c6 |
How to: Capture User Input from a PrintDialog at Run Time
While you can set options related to printing at design time, you will sometimes want to change these options at run time, most likely because of choices made by the user. You can capture user input for printing a document using the xref:System.Windows.Forms.PrintDialog and the xref:System.Drawing.Printing.PrintDocument components.
To change print options programmatically
-
Add a xref:System.Windows.Forms.PrintDialog and a xref:System.Drawing.Printing.PrintDocument component to your form.
-
Set the xref:System.Windows.Forms.PrintDialog.Document%2A property of the xref:System.Windows.Forms.PrintDialog to the xref:System.Drawing.Printing.PrintDocument added to the form.
PrintDialog1.Document = PrintDocument1printDialog1.Document = PrintDocument1;printDialog1->Document = PrintDocument1; -
Display the xref:System.Windows.Forms.PrintDialog component by using the xref:System.Windows.Forms.CommonDialog.ShowDialog%2A method.
PrintDialog1.ShowDialog()printDialog1.ShowDialog();printDialog1->ShowDialog(); -
The user's printing choices from the dialog will be copied to the xref:System.Drawing.Printing.PrinterSettings property of the xref:System.Drawing.Printing.PrintDocument component.