Back to Devexpress

Specify the Number of Copies to Print

xtrareports-7066-desktop-reporting-common-features-printing-winforms-reporting-print-api-specify-the-number-of-copies-to-print.md

latest1.6 KB
Original Source

Specify the Number of Copies to Print

  • Aug 18, 2023

This example demonstrates how you can specify the number of document copies to print.

To do this, assign a report instance to a ReportPrintTool, and handle the PrintingSystemBase.StartPrint event of a Print Tool’s PrintToolBase.PrintingSystem.

csharp
using DevExpress.XtraPrinting;
using DevExpress.XtraReports.UI;
// ...

private void button1_Click(object sender, System.EventArgs e) {
    ReportPrintTool printTool = new ReportPrintTool(new XtraReport1());
    printTool.PrintingSystem.StartPrint += PrintingSystem_StartPrint;
    printTool.Print();
}

void PrintingSystem_StartPrint(object sender, PrintDocumentEventArgs e) {
    // Set the number of document copies to print.
    e.PrintDocument.PrinterSettings.Copies = 3;
}
vb
Imports DevExpress.XtraPrinting
Imports DevExpress.XtraReports.UI
' ...

Private Sub button1_Click(sender As Object, e As System.EventArgs)
    Dim printTool As New ReportPrintTool(New XtraReport1())
    AddHandler printTool.PrintingSystem.StartPrint, AddressOf PrintingSystem_StartPrint
    printTool.Print()
End Sub

Private Sub PrintingSystem_StartPrint(sender As Object, e As PrintDocumentEventArgs)
    ' Set the number of document copies to print.
    e.PrintDocument.PrinterSettings.Copies = 3
End Sub