* 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
3.1 KiB
title, ms.date, dev_langs, helpviewer_keywords, ms.assetid
| title | ms.date | dev_langs | helpviewer_keywords | ms.assetid | |||||
|---|---|---|---|---|---|---|---|---|---|
| Complete Print Jobs | 03/30/2017 |
|
|
23ec74f7-34c5-4710-82a0-ee2914518548 |
How to: Complete Windows Forms Print Jobs
Frequently, word processors and other applications that involve printing will provide the option to display a message to users that a print job is complete. You can provide this functionality in your Windows Forms by handling the xref:System.Drawing.Printing.PrintDocument.EndPrint event of the xref:System.Drawing.Printing.PrintDocument component.
The following procedure requires that you have created a Windows-based application with a xref:System.Drawing.Printing.PrintDocument component on it, which is the standard way of enabling printing from a Windows-based application. For more information about printing from Windows Forms using the xref:System.Drawing.Printing.PrintDocument component, see How to: Create Standard Windows Forms Print Jobs.
To complete a print job
-
Set the xref:System.Drawing.Printing.PrintDocument.DocumentName%2A property of the xref:System.Drawing.Printing.PrintDocument component.
PrintDocument1.DocumentName = "MyTextFile"printDocument1.DocumentName = "MyTextFile";printDocument1->DocumentName = "MyTextFile"; -
Write code to handle the xref:System.Drawing.Printing.PrintDocument.EndPrint event.
In the following code example, a message box is displayed, indicating that the document has finished printing.
Private Sub PrintDocument1_EndPrint(ByVal sender As Object, ByVal e As System.Drawing.Printing.PrintEventArgs) Handles PrintDocument1.EndPrint MessageBox.Show(PrintDocument1.DocumentName + " has finished printing.") End Subprivate void printDocument1_EndPrint(object sender, System.Drawing.Printing.PrintEventArgs e) { MessageBox.Show(printDocument1.DocumentName + " has finished printing."); }private: void printDocument1_EndPrint(System::Object ^ sender, System::Drawing::Printing::PrintEventArgs ^ e) { MessageBox::Show(String::Concat(printDocument1->DocumentName, " has finished printing.")); }(Visual C# and Visual C++) Place the following code in the form's constructor to register the event handler.
this.printDocument1.EndPrint += new System.Drawing.Printing.PrintEventHandler (this.printDocument1_EndPrint);this->printDocument1->EndPrint += gcnew System::Drawing::Printing::PrintEventHandler (this, &Form1::printDocument1_EndPrint);