Example E1765
Visible to All Users

Reporting for WinForms - Print Multiple Reports in a Batch

In this example, the reports are printed in a single batch, instead of sending one report at a time to the printer. The Print dialog box is only called for the first report, the other reports are printed without prompting, with the same print settings.

The PrintTool.Printdialog method is used to print the reports. The StartPrint event is handled to specify print settings.

Files to Review

Documentation

More Examples

Does this example address your development requirements/objectives?

(you will be redirected to DevExpress.com to submit your response)

Example Code

BatchPrinting/Form1.cs(vb)
C#
using System; using System.Windows.Forms; using System.Drawing.Printing; using DevExpress.XtraPrinting; using DevExpress.XtraReports.UI; // ... namespace BatchPrinting { public partial class Form1 : Form { public Form1() { InitializeComponent(); } private PrinterSettings prnSettings; private void button1_Click(object sender, EventArgs e) { XtraReport1 report1 = new XtraReport1(); XtraReport[] reports = new XtraReport[] { new XtraReport2(), new XtraReport3() }; ReportPrintTool pt1 = new ReportPrintTool(report1); pt1.PrintingSystem.StartPrint += new PrintDocumentEventHandler(PrintingSystem_StartPrint); foreach (XtraReport report in reports) { ReportPrintTool pts = new ReportPrintTool(report); pts.PrintingSystem.StartPrint += new PrintDocumentEventHandler(reportsStartPrintEventHandler); } if(pt1.PrintDialog() == true) { foreach(XtraReport report in reports) { ReportPrintTool pts = new ReportPrintTool(report); pts.Print(); } } } void PrintingSystem_StartPrint(object sender, PrintDocumentEventArgs e) { prnSettings = e.PrintDocument.PrinterSettings; } private void reportsStartPrintEventHandler(object sender, PrintDocumentEventArgs e) { int pageCount = e.PrintDocument.PrinterSettings.ToPage; e.PrintDocument.PrinterSettings = prnSettings; // Do this if your reports contain different number of pages, // and you always need to print all pages in a report. e.PrintDocument.PrinterSettings.ToPage = pageCount; } } }

Disclaimer: The information provided on DevExpress.com and affiliated web properties (including the DevExpress Support Center) is provided "as is" without warranty of any kind. Developer Express Inc disclaims all warranties, either express or implied, including the warranties of merchantability and fitness for a particular purpose. Please refer to the DevExpress.com Website Terms of Use for more information in this regard.

Confidential Information: Developer Express Inc does not wish to receive, will not act to procure, nor will it solicit, confidential or proprietary materials and information from you through the DevExpress Support Center or its web properties. Any and all materials or information divulged during chats, email communications, online discussions, Support Center tickets, or made available to Developer Express Inc in any manner will be deemed NOT to be confidential by Developer Express Inc. Please refer to the DevExpress.com Website Terms of Use for more information in this regard.