Skip to main content

PrintDocumentEventHandler Delegate

Represents the method that will handle the PrintingSystemBase.StartPrint event.

Namespace: DevExpress.XtraPrinting

Assembly: DevExpress.Printing.v23.2.Core.dll

NuGet Package: DevExpress.Printing.Core

Declaration

public delegate void PrintDocumentEventHandler(
    object sender,
    PrintDocumentEventArgs e
);

Parameters

Name Type Description
sender Object

An object of any type that triggers the PrintingSystemBase.StartPrint event.

e PrintDocumentEventArgs

A PrintDocumentEventArgs object that provides data for the PrintingSystemBase.StartPrint event.

Remarks

When creating an PrintDocumentEventHandler delegate, you identify the method that will handle the corresponding event. To associate an event with your event handler, add a delegate instance to this event. The event handler is called whenever the event occurs unless you remove the delegate. For more information about event handler delegates, see Events and Delegates in MSDN.

Example

The following example demonstrates how to use the PrintDocumentEventArgs object when handling the PrintingSystemBase.StartPrint event. The example below demonstrates how to programmatically select a printer to print a document at runtime.

using System;
using System.Windows.Forms;
using System.Drawing.Printing;
using DevExpress.XtraPrinting;
using DevExpress.Utils;
// ...

// creating a PrintingSystem object
private PrintingSystem printingSystem1 = new PrintingSystem();
//...

private void button1_Click(object sender, System.EventArgs e) {
   // handling the StartPrint event
   printingSystem1.StartPrint += new PrintDocumentEventHandler(printingSystem_StartPrint);

   // printing the document
   printingSystem1.Print();
}

private void printingSystem_StartPrint(object sender, PrintDocumentEventArgs e) {
   // setting the specific printer's name before printing
   e.PrintDocument.PrinterSettings.PrinterName = PrinterSettings.InstalledPrinters[1];
}
See Also