Files
docs-desktop/dotnet-desktop-guide/framework/winforms/advanced/how-to-capture-user-input-from-a-printdialog-at-run-time.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, 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
csharp
vb
cpp
print options [Windows Forms], changing at run time
printing [Windows Forms], options
print options
run time [Windows Forms], changing print options
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

  1. Add a xref:System.Windows.Forms.PrintDialog and a xref:System.Drawing.Printing.PrintDocument component to your form.

  2. 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 = PrintDocument1  
    
    printDialog1.Document = PrintDocument1;  
    
    printDialog1->Document = PrintDocument1;  
    
  3. 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();  
    
  4. 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.

See also