PrintController.OnStartPrint(PrintDocument, PrintEventArgs) 方法

定义

在派生类中重写时,开始一个确定何时以及如何对文档进行打印的控制序列。When overridden in a derived class, begins the control sequence that determines when and how to print a document.

public:
 virtual void OnStartPrint(System::Drawing::Printing::PrintDocument ^ document, System::Drawing::Printing::PrintEventArgs ^ e);
public virtual void OnStartPrint (System.Drawing.Printing.PrintDocument document, System.Drawing.Printing.PrintEventArgs e);
abstract member OnStartPrint : System.Drawing.Printing.PrintDocument * System.Drawing.Printing.PrintEventArgs -> unit
override this.OnStartPrint : System.Drawing.Printing.PrintDocument * System.Drawing.Printing.PrintEventArgs -> unit
Public Overridable Sub OnStartPrint (document As PrintDocument, e As PrintEventArgs)

参数

document
PrintDocument

PrintDocument,它表示当前正在打印的文档。A PrintDocument that represents the document currently being printed.

e
PrintEventArgs

包含事件数据的 PrintEventArgsA PrintEventArgs that contains the event data.

注解

OnStartPrint 引发事件后立即调用 PrintDocument BeginPrintOnStartPrint is called immediately after the PrintDocument raises the BeginPrint event.

使用 OnStartPrint 方法来确定何时以及如何打印文档。Use the OnStartPrint method to determine when and how to print a document. 例如,你可以将打印延迟30分钟,或者调整文档的打印机设置。For example, you can delay printing for 30 minutes or adjust the printer settings for the document. OnStartPrint 创建 Graphics 发送到打印机的。OnStartPrint creates the Graphics that is sent to the printer. OnStartPrint调用后,方法会 OnStartPage 将设置 Graphics 为单个页面中的一个。After OnStartPrint is called, the OnStartPage method sets the Graphics to one of a single page. OnEndPage方法会清除 Graphics ,而方法会 OnEndPrint 释放对象。The OnEndPage method clears the Graphics, while the OnEndPrint method deallocates the object.

OnStartPrint方法是验证是否有效的好地方 PrinterSettingsThe OnStartPrint method is a good place to verify that PrinterSettings are valid.

适用于

另请参阅