ActiveReports 18 .NET Edition
Developers / Working with Reports / Section Report / Printer Settings for Section Reports
In This Topic
    Printer Settings for Section Reports
    In This Topic

    In a Section Report, you can modify various printer settings or print multiple copies of a report at design time and at run time.

    Printer Settings

    Section reports depend on default printer settings may require some extra configuration.

    C# code. Paste INSIDE the ReportStart event.
    Copy Code
    var rpt = new SectionReport();
    rpt.Document.Printer.Name = "";
    

    Note: It is recommended to set the printer name as empty if you not sure about target environments.

    At design time, you can set up duplex printing, page orientation, collation, and page size in the Printer Settings tab of the Report Settings Dialog.

    Set up duplex printing in Printer Settings

    1. In the Report Explorer, double-click the Settings node.
    2. In the Report Settings dialog that appears, click Printer Settings.
    3. On the Printer Settings page, next to Duplex, select one of the following options:
      • Printer Default: The report uses the default settings of the selected printer.
      • Simplex: Turns off duplex printing.
      • Horizontal: Prints horizontally on both sides of the paper.
      • Vertical: Prints vertically on both sides of the paper.
    4. Click OK to return to the report.

    Use code to set up duplex printing

    1. Double-click the gray area below the design surface to create an event-handling method for the report's ReportStart event.
    2. Add the following code to the handler to set up duplexing.

      To write the code in Visual Basic.NET

      Visual Basic.NET code. Paste INSIDE the ReportStart event.
      Copy Code
      Me.PageSettings.Duplex = GrapeCity.ActiveReports.Printing.Duplex.Horizontal

      To write the code in C#

      C# code. Paste INSIDE the ReportStart event.
      Copy Code
      this.PageSettings.Duplex = GrapeCity.ActiveReports.Printing.Duplex.Horizontal;

    Set page orientation on the Printer Settings page

    1. In the Report Explorer, double-click the Settings node.
    2. In the Report Settings dialog that appears, click Printer Settings.
    3. On the Printer Settings page, in the Orientation section, select either Default, Portrait, or Landscape.
    4. Click OK to return to the report.

    Use code to change page orientation

    1. Double-click the gray area below the design surface to create an event-handling method for the report's ReportStart event.
    2. Add the following code to the handler to change the page orientation of the report for printing.
      Note: Page orientation can only be modified before the report runs. Otherwise, changes made to the page orientation are not used during printing.

      The following example shows what the code for the method looks like.

      To write the code in Visual Basic.NET

      Visual Basic.NET code. Paste INSIDE the ReportStart event.
      Copy Code
      Me.PageSettings.Orientation = GrapeCity.ActiveReports.Document.Section.PageOrientation.Landscape

      To write the code in C#

      C# code. Paste INSIDE the ReportStart event.
      Copy Code
      this.PageSettings.Orientation = GrapeCity.ActiveReports.Document.Section.PageOrientation.Landscape;

    Multiple Copies

    You can print multiple copies using the Print dialog in the Preview tab or in the Viewer, or you can use code to set the number of copies to print.

    Set multiple copies in the print dialog

    1. With a report displayed in the viewer or in the preview tab, click Print.
    2. In the Print dialog that appears, next to Number of copies, set the number of copies that you want to print.

    Use code to set multiple copies

    1. Double-click in the gray area below the design surface to create an event-handling method for the report's ReportStart event.
    2. Add the following 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.

      To write the code in Visual Basic.NET

      Visual Basic.NET code. Paste INSIDE the ReportStart event.
      Copy Code
      Me.Document.Printer.PrinterSettings.Copies = 5
      Visual Basic.NET code. Paste INSIDE the ReportEnd event.
      Copy Code
      Me.Document.Printer.Print()

      To write the code in C#

      C# code. Paste INSIDE the ReportStart event.
      Copy Code
      this.Document.Printer.PrinterSettings.Copies = 5;
      C# code. Paste INSIDE the ReportEnd event.
      Copy Code
      this.Document.Printer.Print();