ActiveReports 6 Online Help Send comments on this topic.
Overlaying Reports (Letterhead)
See Also
ActiveReports 6 > ActiveReports User Guide > Samples and Walkthroughs > Walkthroughs > Overlaying Reports (Letterhead)

Glossary Item Box

ActiveReports allows you to overlay static report formats over data reports. This walkthrough illustrates how to overlay an ActiveReport with a static letterhead report.

This walkthrough is split up into the following activities:

Tip: For basic steps like adding a report to a Visual Studio project and viewing a report, please see the Basic Data Bound Reports walkthrough.

To complete the walkthrough, you must have access to the Northwind database.
A copy is located at C:\Program Files\GrapeCity\ActiveReports 6\Data\NWIND.MDB (on a 64-bit Windows operating system, a copy is located in C:\Program Files (x86)\GrapeCity\ActiveReports 6\Data\NWIND.MDB).

When you have completed this walkthrough, you will have a report that looks similar to the following.

To connect rptData to a data source

  1. Add two reports to a Visual Studio project, naming them rptLetterhead and rptData.
  2. Click the gray report DataSource icon on the Detail section band to open the Report Data Source dialog.
  3. On the OLE DB tab, next to Connection String, click the Build button.
  4. In the Data Link Properties window that appears, select Microsoft Jet 4.0 OLE DB Provider and click the Next button.
  5. Click the ellipsis (...) button to browse to the Northwind database. Click Open once you have selected the appropriate access path.
  6. Click OK to close the window and fill in the Connection String field.
  7. In the Query field, enter the following SQL query
    SQL Query Copy Code
    SELECT * FROM Customers ORDER BY Country
  8. Click OK to save the data source and return to the report design surface.

To add controls to rptData

  1. Select the PageHeader section, and in the Properties Window, set the Height property to 0.65. (This will match the height of the page header in the template.)
  2. Right-click the report and select Insert > GroupHeader/Footer to add group header and group footer sections.
  3. Make the following changes to the group header:
    • Change the Name property to ghCustomers
    • Change the BackColor property to MediumSlateBlue
    • Change the CanShrink property to True
    • Change the DataField property to Country
    • Change the GroupKeepTogether property to FirstDetail
    • Change the KeepTogether property to True
  4. Add the following controls to ghCustomers with properties set as indicated:

    ShowGroup header labels

    Control Miscellaneous Text (or DataField) Size Location
    TextBox Bold
    ForeColor = White
    Font Size = 12
    ="Customers in " + Country
    (DataField)
    2, 0.2 in 0, 0 in
    Label Bold
    ForeColor = DarkSlateBlue
    ID 0.6, 0.198 in 0, 0.2 in
    Label Bold
    ForeColor = DarkSlateBlue
    Company Name 1.1, 0.198 in 0.7, 0.2 in
    Label Bold
    ForeColor = DarkSlateBlue
    Address 1, 0.198 in 2.7, 0.2 in
    Label Bold
    ForeColor = DarkSlateBlue
    City 1, 0.198 in 5.5, 0.2 in
  5. Make the following changes to the detail section:
    • Change the BackColor property to LightGray
    • Change the CanShrink property to True
  6. In the Report Explorer, expand the Fields node, then the Bound node. Drag the following fields onto the detail section and set the properties of each textbox as indicated.

    ShowDetail fields

    Field Size Location
    CustomerID 0.6, 0.2 in 0, 0 in
    CompanyName 2, 0.2 in 0.7, 0 in
    Address 2.8, 0.2 in 2.7, 0 in
    City 1, 0.2 in 5.5, 0 in
  7. Change the group footer's Height property to 0.

To add static controls to rptLetterhead

  1. Make the following changes to the page header:
    • Change the BackColor property to DarkSlateBlue
    • Change the Height property to 0.65
  2. Add the following controls to the page header with properties set as indicated:

    ShowPage header labels

    Control Miscellaneous Size Location
    Label Size = 36
    Style = Bold
    ForeColor = White
    Text = GrapeCity
    3.7, 0.65 in 0, 0 in
    Picture PictureAlignment = TopLeft
    Image (click ellipsis, navigate to C:\Program Files\GrapeCity\ActiveReports 6\Introduction (on a 64-bit Windows operating system, navigate to C:\Program Files (x86)\GrapeCity\ActiveReports 6\Introduction) and select itopimage1.gif)
    3, 0.65 in 3.5, 0 in
  3. Make the following changes to the page footer:
    • Change the BackColor property to DarkSlateBlue
  4. Add a label with the following properties to the page footer:

    ShowPage footer label

    Miscellaneous ForeColor Text Size Location
    Alignment = Center
    Style = Bold
    White (919) 460-4551, http://www.grapecity.com, powersales@grapecity.com 6.5, 0.2 in 0, 0 in

Adding code to overlay the data report pages with the letterhead report

ShowTo write the code in Visual Basic.NET

  • Add the ActiveReports viewer control to the Windows Form. Then, double-click the top of the Windows Form to create an event-handling method for the form's Load event. Add code to the handler to:
    • Set the viewer to display the rptData report document
    • Overlay rptLetterhead on rptData

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

Visual Basic.NET code. Paste INSIDE the Form Load event. Copy Code
   Dim rpt As New rptData()
   rpt.Run()
   Viewer1.Document = rpt.Document      
   Dim rpt2 As New rptLetterhead()
   rpt2.Run()
   Dim i As Integer
   For i = 0 To rpt.Document.Pages.Count - 1
      rpt.Document.Pages(i).Overlay(rpt2.Document.Pages(0))
   Next

ShowTo write the code in C#

  • Add the ActiveReports viewer control to the Windows Form. Then, double-click the top of the Windows Form to create an event-handling method for the form's Load event. Add code to the handler to:
    • Set the viewer to display the rptData report document
    • Overlay rptLetterhead on rptData

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

C# code. Paste INSIDE the Form Load event. Copy Code
   rptData rpt = new rptData();
   rpt.Run();
   viewer1.Document = rpt.Document;
   rptLetterhead rpt2 = new rptLetterhead();
   rpt2.Run();
   for(int i = 0; i < rpt.Document.Pages.Count; i++)
   {
      rpt.Document.Pages[i].Overlay(rpt2.Document.Pages[0]);
   }

See Also