Glossary Item Box

Samples | Walkthroughs | OutputFormat Strings | GroupKeepTogether enumeration

See Also ActiveReports for .NET 2 Online Help Send feedback to Data Dynamics

Walkthrough: Adding Pages

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 (NWind.mdb).

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

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. Click on Project > Add New Item.
  3. Select ActiveReports file and rename the file rptInsertPage.
  4. Click Open.
  5. Click on Project > Add New Item.
  6. Select ActiveReports 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 yellow report DataSource icon in the Detail section. This brings up the report DataSource dialog box.
  2. Click on Build...
  3. Select Microsoft Jet 4.0 OLE DB Provider and click Next >>
  4. Click on the ellipsis to browse for the access path to NWind.mdb. Click Open once you have selected the appropriate access path.
  5. Click OK to continue.
  6. In the Query field, type "Select * from products order by productname".
  7. Click OK to return to the report design surface.

Adding controls to display the data

To add controls to the reports

  1. Add a GroupHeader/Footer section to rptInsertPage.
  2. Make the following changes to the group header:
    • Change the name to ghProducts
    • Change the DataField property to ProductName
    • Change the GroupKeepTogether property to FirstDetail
    • Change the KeepTogether property to True
  3. Add the following controls to the GroupHeader section of rptInsertPage:

    Control Name Text/Caption Location
    Label lblProductID Product ID 0, 0
    Label lblProductName Product Name 1.312, 0
    Label lblUnitsInStock Units In Stock 2.625, 0
    Label lblUnitsOnOrder Units On Order 3.937, 0
    Label lblUnitPrice Unit Price 5.25, 0

  4. Add the following controls to the Detail section of rptInsertPage:

    Control DataField Name Text/Caption Misc Details Location
    TextBox ProductID txtProductID Product ID (Empty string) 0, 0
    TextBox ProductName txtProductName Product Name (Empty string) 1.312, 0
    TextBox UnitsInStock txtUnitsInStock Units In Stock (Empty string) 2.635, 0
    TextBox UnitPrice txtUnitPrice Unit Price OutputFormat = Currency 5.25, 0
    TextBox UnitsOnOrder txtUnitsOnOrder Units On Order (Empty string) 3.937, 0

  5. Add the following controls to the PageHeader section of rptCoverPage:

    Control Name Text/Caption Section Misc Details Location
    Label lblCompanyInfo Company Street Name Company City, Company State Company Zip Code PageHeader Text-Align = Center 0.0625, 0.0625
    Label lblCompanyName Company Name PageHeader Text-Align = Center 2.437, 0.0625
    Line Line1 (Empty string) PageHeader (Empty string) X1 = 2.437

    Y1 = 0.0625

    X2 = 6.437

    Y2 = 0.0625

     
    Line Line2 (Empty string) PageHeader (Empty string) X1 = 2.437

    Y1 = 0.625

    X2 = 6.437

    Y2 = 0.625

    Line Line3 (Empty string) PageHeader (Empty string) X1 = 0.0625

    Y1 = 0.0625

    X2 = 0.0625

    Y2 = 0.625

    Line Line4 (Empty string) PageHeader (Empty string) X1 = 2.312

    Y1 = 0.0625

    X2 = 2.312

    Y2 = 0.625

    TextBox txtComments Comments: Detail (Empty string) 0.875, 2.437
  6. Add the following controls to the Detail section of rptCoverPage:

    Control Name Text/Caption Misc Details Location
    Label lblFax Fax Text-Align = Center 0.0625, 0.0625
    Label lblTo To: (Empty string) 1, 0.75
    Label lblFax2 Fax #: (Empty string) 1, 1
    Label lblPhone Phone #: (Empty string) 1, 1.25
    Label lblRe Re: (Empty string) 1, 1.5
    TextBox txtTo (Empty string) (Empty string) 1.875, 0.75
    TextBox txtFax (Empty string) (Empty string) 1.875, 1
    TextBox txtPhone (Empty string) (Empty string) 1.875, 1.25
    TextBox txtRe (Empty string) (Empty string) 1.875, 1.5
    Label lblCC CC: (Empty string) 3.0625, 1.5
    Label lblDate Date: (Empty string) 3.0625, 1.25
    Label lblPages Pages: (Empty string) 3.0625, 1
    Label lblFrom From (Empty string) 3.0625, 0.75
    TextBox txtFrom (Empty string) (Empty string) 3.937, 0.75
    TextBox txtPages (Empty string) (Empty string) 3.937, 1
    TextBox txtDate (Empty string) (Empty string) 3.937, 1.25
    TextBox txtCC (Empty string) (Empty string) 3.937, 1.5
    CheckBox chkUrgent Urgent (Empty string) 0.5, 2.0625
    CheckBox chkForReview For Review (Empty string) 1.5, 2.0625
    CheckBox chkPleaseComment Please Comment (Empty string) 2.75, 2.0625
    CheckBox chkPleaseReply Please Reply (Empty string) 4.437, 2.0625
    Line Line5 (Empty string) (Empty string) X1 = 0.0625

    Y1 = 2.375

    X2 = 6.437

    Y2 = 2.375

    TextBox txtComments Comments: (Empty string) 0.875, 2.437

Adding code to the Form_Load event

To write the code in Visual Basic

To write the code in C#

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.

Samples | Walkthroughs | OutputFormat Strings | GroupKeepTogether enumeration

 

 


Copyright © 2004-2005 Data Dynamics, Ltd. All rights reserved.