Walkthrough Multiple Copies

This walkthrough illustrates how to set multiple copies for printing a report. This walkthrough is split up into the following activities:

• Setting multiple copies for printing a report from the print dialog at run time

• Setting multiple copies in code for printing a report

• Using code to set multiple copies for printing

• Viewing the report

Setting multiple copies for printing a report from the print dialog at run time To set multiple copies for printing a report from the print dialog at run time

1. Press F5 to run an existing ActiveReport.

2. Click on the printer icon in the viewer window.

M Forml

3. In the Copies box, select the number of copies needed.

Using code to set multiple copies for printing at run time

To write the code in Visual Basic

• Right-click in any section of the design window of your report, and click on View Code to display the code view for the report. At the top left of the code view for the report, click the drop-down arrow and select (Base Class Events). At the top right of the code window, click the drop-down arrow and select ReportStart. This creates an event-handling method for the report's ReportStart event. Add code to the handler to:

• Set multiple copies of the report for printing To write the code in C#

• Click in the gray section underneath the report to select the report. Click on the events icon in the Properties window to display available events for the report. Double-click ReportStart. This creates an event-handling method for the report's ReportStart event. Add code to the handler to:

• Set multiple copies of the report for printing

The following example shows what the code for the method looks like for printing five copies:

[Visual Basic]

Private Sub rptPrint_ReportStart(ByVal sender As Object, ByVal e As System.EventArgs) Hanc Me.Document.Printer.PrinterSettings.Copies = 5 Me.Document.Print(false, false)

End Sub

private void rptPrint_ReportStart(object sender, System.EventArgs eArgs) {

this.Document.Printer.PrinterSettings.Copies = 5; this.Document.Print(false, false);

Viewing the report To view the report

1. Add the ActiveReports viewer control to a Windows Form.

2. Add the code needed to set the viewer document equal to the report document. See Using the ActiveReports WinForm Viewer for help.

Was this article helpful?

0 0

Post a comment