ActiveReports for .NET 3 Online Help Request technical support
Walkthrough: Hyperlinks and Bookmarks
See Also
User Guide > Samples and Walkthroughs > Walkthroughs > Standard Edition Walkthroughs > Advanced > Hyperlinks Walkthroughs > Walkthrough: Hyperlinks and Bookmarks

Glossary Item Box

ActiveReports allows you to use the hyperlink property to reference back to the bookmarks collection.

This walkthrough illustrates how to add hyperlinks to a report that references items in the bookmarks collection and create a directory to match the items in the bookmarks collection.

This walkthrough is split up into the following activities:

To complete the walkthrough, you must  have access to the Northwind database.

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. From the Project menu, select Add New Item.
  3. Select ActiveReports 3.0 File and rename the file rptMain.
  4. Click Open.
  5. From the Project menu, select Add New Item.
  6. Select ActiveReports 3.0 File and rename the file rptBookmarks.
  7. Click Open.

Connecting rptMain to a data source

To connect the report to a data source

  1. Click 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 suppliers order by CompanyName".
  8. Click OK to return to the report design surface.

Adding controls to rptMain display the data

To add controls to the report

  1. Add a GroupHeader/Footer section to rptMain by right-clicking the design surface of the report and selecting Insert > Group Header/Footer.
  2. Make the following changes to the group header:
    • Change the Name property to ghSuppliers
    • Change the DataField property to CompanyName
    • Change the GroupKeepTogether property to All
    • Change the KeepTogether property to True
  3. Add the following controls to ghSuppliers:
    Control Name Text Location
    Label lblCompanyName Company Name 0, 0
    Label lblContactName Contact Name 1.562, 0
    Label lblPhone Phone # 2.687, 0
    Label lblFax Fax # 3.812, 0
    Label lblHomePage1 Home Page 4.875, 0
  4. In the Report Explorer, expand the Fields node, then the Bound node. Drag the following fields onto the detail section of rptMain and set the following properties of each textbox.
    Field Text Location
    CompanyName Company Name 0, 0
    ContactName Contact Name 1.562, 0
    Phone Phone 2.687, 0
    Fax Fax 3.812, 0
    HomePage Home Page 4.875, 0
  5. Set the CanShrink property of the detail section to True.
  6. Add the following controls to the PageFooter section:
    Control Name Text Miscellaneous Location
    Label lblEmail Need Assistance? E-mail Support: Support@company.com HyperLink = mailto:support@company.com 0, 0.125
    Label lblHomePage Visit our home page: www.datadynamics.com HyperLink = www.datadynamics.com 0, 0.375

    Adding controls to rptBookmarks display the data

    To add controls to the report

    1. Set the CanShrink property of the detail section to True.
    2. Add the following controls to the PageHeader section:
      Control Name Text Location
      Label lblDirectory Directory 0.5, 0
      Label lblCompanyName Company Name 1.125, 0.437
      Label lblPage Page 3.312, 0.437
      Line Line1 X1 = 0
      X2 = 6.5
      Y1 = 0.697
      Y2 = 0.697
    3. Add the following controls to the Detail section:
      Control Name Text Location
      TextBox txtEntry Company Name 1.125, 0
      TextBox txtPage Page 3.312, 0

    Adding the code to rptMain's Detail_Format event

    Add code to the Format event to parse the URL out of the HomePage field and assign it to the HyperLink property of txtHomePage, and to remove the URL markers from the text displayed in txtHomePage.

    To write the code in Visual Basic or C#

    Adding the code to rptMain's ReportEnd event

    Add code to the ReportEnd event to run rptBookmarks and insert its pages collection at the beginning of rptMain.

    To write the code in Visual Basic

    To write the code in C#

    Adding the code to rptBookmarks' Detail_Format event

    Add code to the Format event to create a hyperlink that points to a bookmark and to display the page number of the bookmark.

    To write the code in Visual Basic or C#

    Adding code to rptBookmarks' FetchData event

    Add code to the FetchData event to get the page number of the bookmark.

    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 Windows Form Viewer for help.
    You can quickly view your report at design time by clicking the Preview tab at the bottom of the designer.

    Viewing the Bookmarks Collection 

    To view the Bookmarks collection 

    1. Press F5 to run the report.
    2. Click on the "Table of Contents" icon to view the Bookmarks collection.

    See Also

    ©2009. All Rights Reserved.