Implement the print function in C # (use of printdialog and printdocument in C)
Using printdialog in C # allows you to conveniently print programs.
The procedure is as follows:
Create a printdialog instance. As follows:System. Windows. Forms. printdialog printdialog1 = new printdialog ();
Create an instance of
Printing in C # using PrintDialog can be very convenient to achieve the printing function of the program.
The steps are as follows:
Create an instance of PrintDialog. As follows:
System.Windows.Forms.PrintDialog printdialog1=new PrintDialog ();
Create an instance of PrintDocument. as follows:
System.Drawing.Printing.PrintDocument Doctoprint =
New System.Drawing.Printing.PrintDocument ();
Sets the event ha
Using PrintDialog in C # allows you to conveniently print programs.
The procedure is as follows:
Create a PrintDialog instance. As follows:System. Windows. Forms. PrintDialog PrintDialog1 = new PrintDialog ();
Create an instance of PrintDocument as follows:System. Drawing. Printing. PrintDocument docToPrint =New System. Drawing. Printing.
C # winformprint excel(use npoi?spire.xls + PrintDocument to print excel directly ),
Preface
C # generate and print the Excel report for the winform program. In order not to install the corresponding Office components, I chose NPOI to generate the Excel report and used the PrintDocument control of winform to trigger th
I. PrintDocument class.
The PrintDocument class is included in the System. drawing. printing is used for communication and transmission with printers. It has special attributes to specify which printer should be selected for Printing, you can also set the default settings for the printed paper.
Usage: PrintDocument pdt = new
In the window printing process, we found that the image was still very good, that is, painting on printdocument. Just like painting on canvas, what would you like? First, let's look at the sample code.
Private void button#click (Object sender, routedeventargs e) {var printdocument = new printdocument (); // specifies the printer
All subscription events of the printdocument instance are as follows:
1. Create a printdocument instance as follows:System. Drawing. Printing. printdocument doctoprint =New system. Drawing. Printing. printdocument ();2. Set the event processing function for the printer to start printing. The original function is as fol
The printdocument control sets the printed document. In the printdocument control, the printpage event and print method of the control are common. The printpage event occurs when the output of the current page needs to be printed. Call the print method to start the document printing process. The following example shows how to use the printdocument control.For exa
usingSystem;usingSystem.Collections.Generic;usingSystem.ComponentModel;usingSystem.Data;usingSystem.Drawing;usingSystem.Text;usingSystem.Windows.Forms;usingSystem.Drawing.Printing;namespaceDemo{publicpartialclass printother:form{ PublicPrintother () {InitializeComponent ();}//The PrintDocument class is the core of the printing function that encapsulates the printing-related properties, events, and methodsPrintDocument
Recently, there is a requirement in a project that requires one or more big texts, just like the ones in my graduation thesis.
ArticleOutput to the printer. I have referred to many public libraries including codeproject.
Source codeIn the
System. Drawing. printing;Classes in The namespace can be used for application.Program.The printed category isPrintdocument, MethodPrint ()Will trigger a series of trial use, and finally useOnprintpage (),Send the response to the printer.
Print structure:The following section lists the main parts of the print structure.
Description:Printdocument : Is the most important type. Almost all print categories are related to this category. To print a text example, you must
4.1 Print and Print previewPrint and print Preview is a feature that an editor must have, and this section describes how to implement print and print previews. In general, the following menu items are implemented: Print, Print preview, page setup.4.8.1PrintDocument classThe PrintDocument component is the class used to complete the printing, with its common properties, methods, and events as follows:L Property DocumentName: A string type that records t
Print recently in the forum many netizens asked "How to install all the printers in Windows listed", in the following program we will be installed in the system of the printer listed in the list box, while the default printer set the default value.
In the following program we used two main classes, all of the printer list out of the PrinterSettings class, get the system default printer used PrintDocument class, let's do a hands-on.
To create a new W
valueColorDialog. ShowDialog ();RichTextBox1.SelectionColor = colorDialog. Color;}
It is easy to implement the color dialog box (ColorDialog). In fact, it is not just a color dialog box, but C # is also very easy to learn. After finishing the ColorDialog dialog box, let's talk about Printing and page settings.
PageSetupDialog)
In fact, there is not much to talk about page settings (PageSetupDialog). Now, I will list the common attributes in Pag
. The printdocument class is the core of printing.Code.
To implement printing, you must first construct a printdocument object to add a printing event,Printdocument. printpage + = new printpageeventhandler (this. printdocument_printpage)Printing actually calls the graphics class method for drawing. The following code is rewritten according to the routine provide
such a simple function?
Check a lot of information, the Internet search for a long time, found no similar examples, looked at the MSDN, only to find that, to VB.net, VB so good printer disappeared, for the description of MSDN: http://msdn.microsoft.com/zh-tw/ library/cc438273 (vs.71). aspx
"The Printer object in Visual Basic 6.0 is replaced by the PrintDocument component in Visual Basic. NET. The behavior of the two is different, but in most cases
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.