PrintingSystemBase.StartPrint Event

Occurs before the printing system's document is printed.

Namespace: DevExpress.XtraPrinting

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

Declaration

public event PrintDocumentEventHandler StartPrint
Public Event StartPrint As PrintDocumentEventHandler

Event Data

The StartPrint event handler receives an argument of the PrintDocumentEventArgs type. The following properties provide information specific to this event.

Property Description
PrintDocument Gets the object that sends the document's output to a printer.

Remarks

You can use the StartPrint event to change printing settings just prior to printing the document.

This event fires only for Windows Forms and WPF applications.

Consider the following specifics of raising this event from UI:

  • In Windows Forms applications, this event is raised after clicking the Qucik Print or Print toolbar button.
  • In WPF applications, this event is raised after clicking the Quick Print toolbar button or the OK button in the Print Dialog.

Examples

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