ActiveReports for .NET 3 Online Help Request technical support
Walkthrough: Adding Pages
See Also
User Guide > Samples and Walkthroughs > Walkthroughs > Standard Edition Walkthroughs > Advanced > Modifying Report Documents Walkthroughs > Walkthrough: Adding Pages

Glossary Item Box

ActiveReports allows you to add pages to your report in Visual Studio for previewing in the viewer control or printing. The document containing the inserted pages can also be saved to an RDF file or exported.

This walkthrough illustrates how to create two reports and insert the second report as a cover page for the first one.

This walkthrough is split up into the following activities:

To complete the walkthrough, you must have access to the Northwind database.
A copy is located at C:\Program Files\Data Dynamics\ActiveReports for .NET 3.0\Data\NWIND.MDB.

When you have completed this walkthrough, you will have a report that looks similar to the following. Please note that this image reflects a "1 X 2 Pages" view.

Adding two ActiveReports to a Visual Studio project

To add two ActiveReports to a Visual Studio project

  1. Open a new project in Visual Studio.
  2. From the Project menu, select Add New Item.
  3. Select ActiveReports 3.0 File and rename the file rptInsertPage.
  4. Click Open.
  5. From the Project menu, select Add New Item.
  6. Select ActiveReports 3.0 File and rename the file rptCoverPage.
  7. Click Open.

Connecting the report to a data source

To connect rptInsertPage to a data source

  1. Click on the gray report DataSource icon in the Detail section to open the report DataSource dialog.
  2. Select the "OLE DB" tab.
  3. Click the Build button.
  4. Select Microsoft Jet 4.0 OLE DB Provider and click Next.
  5. Click the ellipsis button to browse for the access path to the Northwind database. Click Open once you have selected the appropriate access path.
  6. Click OK to continue.
  7. In the Query field, type "Select * from products order by productname".
  8. Click OK to return to the report design surface.

Adding controls to display the data

To add controls to rptInsertPage

  1. Make the following changes to the PageHeader section:
    • Change the BackColor property to LightSteelBlue
  2. Add labels with the following properties to the page header:

    Font Style Name Text Location
    Bold lblProductID Product ID 0, 0
    Bold lblProductName Product Name 1.3, 0
    Bold lblUnitsInStock Units In Stock 2.65, 0
    Bold lblUnitsOnOrder Units On Order 3.9, 0
    Bold lblUnitPrice Unit Price 5.25, 0

  3. In the Report Explorer, expand the Fields node, then the Bound node. Drag the following fields onto the detail section and set the following properties of each textbox as indicated. 

    Field Text Miscellaneous Location
    ProductID Product ID 0, 0
    ProductName Product Name 1.3, 0
    UnitsInStock Units in Stock 2.65, 0
    UnitsOnOrder Units on Order 3.9, 0
    UnitPrice Unit Price OutputFormat = Currency 5.25, 0

To add controls to rptCoverPage

  1. Make the following changes to the PageHeader section:
    • Change the Height property to 0.8
    • Change the BackColor property to LightSlateGray
  2. Add the following controls to the page header:
    Control Name Text Miscellaneous Location
    Label lblCompanyInfo Company Street Name Company City, Company State Company Zip Code

    Alignment = Center

    Size = 2, 0.56

    0.2, 0.13
    Label lblCompanyName Company Name Font Size = 16, Style = Bold 3.5, 0.25
    Line Line1

          

    X1 = 2.3

    X2 = 6.4

    Y1 = 0.06

    Y2 = 0.06

    Line Line2

         

     

    X1 = 2.3

    X2 = 6.4

    Y1 = 0.72

    Y2 = 0.72

    Line Line3

        

    X1 = 2.3 

    X2 = 2.3

    Y1 = 0.06

    Y1 = 0.72

    Line Line4

        

    X1 = 6.4

    X2 = 6.4 

    Y1 = 0.06

    Y2 = 0.72

  3. Set the Height property of the Detail section to 2.8.
  4. Add the following controls to the detail section:

    Control Name Text Miscellaneous Location
    Label lblFax Fax Font Size = 24, Style = Bold 0.25, 0
    Label lblTo To: Font Size = 12, Style = Bold 1, 0.75
    Label lblFax2 Fax #: Font Size = 12, Style = Bold 1, 1
    Label lblPhone Phone #: Font Size = 12, Style = Bold 1, 1.25
    Label lblRe Re: Font Size = 12, Style = Bold 1, 1.5
    Label lblCC CC: Font Size = 12, Style = Bold 3, 1.5
    Label lblDate Date: Font Size = 12, Style = Bold 3, 1.25
    Label lblPages Pages: Font Size = 12, Style = Bold 3, 1
    Label lblFrom From Font Size = 12, Style = Bold 3, 0.75
    CheckBox chkUrgent Urgent 0.5, 2
    CheckBox chkForReview For Review 1.5, 2
    CheckBox chkPleaseComment Please Comment 2.75, 2
    CheckBox chkPleaseReply Please Reply 4.5, 2
    Line Line5

     

    X1 = 0.06

    X2 = 6.44

    Y1 = 2.38

    Y2 = 2.38

    Label lblComments Comments: 1, 2.5

Adding code to the detail format event of rptInsertPage to alternate colors

To write the code in Visual Basic or C#

Adding code to the Windows Form Load event

To write the code in Visual Basic or C#

Viewing the report

To view the report

You can quickly view your report at design time by clicking the Preview tab at the bottom of the designer.

Adding code to insert a page into a specified report location using the AddNew() method

To write the code in Visual Basic or C#

See Also

©2009. All Rights Reserved.