Glossary Item Box

Samples | Walkthroughs | OutputFormat Strings

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

Walkthrough: Hyperlinks and Simulated Drill-Down Reporting

Hyperlinks can be used in Active Reports to simulate drill-down reporting.

This walkthrough illustrates how to set up hyperlinks in a report to simulate drill-down reporting.

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 finished this walkthrough, you will have a report that looks similar to the following.

Adding three ActiveReports to a Visual Studio project

To add three 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 rptMain.
  4. Click Open.
  5. Click on Project > Add New Item.
  6. Select ActiveReports file and rename the file rptDrillDown1.
  7. Click Open.
  8. Click on Project > Add New Item.
  9. Select ActiveReports file and rename the file rptDrillDown2.
  10. Click Open.

Connecting rptMain to a data source

To connect the report 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 customers order by customerID".
  7. Click OK to return to the report design surface.

Connecting rptDrillDown1 to a data source

To connect the report 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 orders where customerID = '<%customerID%>' order by orderdate".
  7. Click OK to return to the report design surface.
  8. In the properties grid, change the ShowParametersUI property for rptDrillDown1 to False to allow rptMain to pass in the parameter without requesting it from the user.

Connecting rptDrillDown2 to a data source

To connect the report 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 [order details] where orderID = <%orderID||10248%> order by productid".
    Note: Setting a default value for the parameter in this query allows you to see fields in the Report Explorer instead of an error message.
  7. Click OK to return to the report design surface.
  8. In the properties grid, change the ShowParametersUI property for rptDrillDown2 to False to allow rptMain to pass in the parameter without requesting it from the user.

Adding controls to display the data

To add controls to the reports

  1. Add the following controls to rptMain, naming them as indicated:

     

    Control DataField Name Text/Caption Section Location
    Label (Empty string) lblCustomer Customer PageHeader 0, 0
    Label (Empty string) lblCompanyName Company Name PageHeader 1.1875, 0
    Label (Empty string) lblContactName Contact Name PageHeader 3.5625, 0
    TextBox CustomerID txtCustomerID Customer ID Detail 0, 0
    TextBox CompanyName txtCompanyName Company Name Detail 1.1875, 0
    TextBox ContactName txtContactName Contact Name Detail 3.5625, 0

     

  2. Add the following controls to rptDrillDown1, naming them as indicated:

     

    Control DataField Name Text/Caption Section Location
    Label (Empty string) lblCustomerID CustomerID PageHeader 0, 0
    Label (Empty string) lblOrderID OrderID PageHeader 1.1875, 0
    Label (Empty string) lblEmployeeID EmployeeID PageHeader 2.4375, 0
    Label (Empty string) lblOrderDate Order Date PageHeader 3.625, 0
    Label (Empty string) lblShippedDate Shipped Date PageHeader 4.8125, 0
    TextBox CustomerID txtCustomerID Customer ID Detail 0, 0
    TextBox OrderID txtOrderID Order ID Detail 1.1875, 0
    TextBox EmployeeID txtEmployeeID Employee ID Detail 2.4375, 0
    TextBox OrderDate txtOrderDate Order Date Detail 3.625, 0
    TextBox ShippedDate txtShippedDate Shipped Date Detail 4.8125, 0
  3. Add the following controls to rptDrillDown2, naming them as indicated:

     

    Control DataField Name Text/Caption Misc Details Section Location
    Label (Empty string) lblOrderID Order ID (Empty string) PageHeader 0, 0
    Label (Empty string) lblProductID Product ID (Empty string) PageHeader 1.1875, 0
    Label (Empty string) lblUnitPrice Unit Price (Empty string) PageHeader 2.375, 0
    Label (Empty string) lblQuantity Quantity (Empty string) PageHeader 3.5625, 0
    Label (Empty string) lblDiscount Discount (Empty string) PageHeader 4.75, 0
    TextBox OrderID txtOrderID Order ID (Empty string) Detail 0, 0
    TextBox ProductID txtProductID Product ID (Empty string) Detail 1.1875, 0
    TextBox UnitPrice txtUnitPrice Unit Price OutputFormat = Currency Detail 2.375, 0
    TextBox Quantity txtQuantity Quantity (Empty string) Detail 3.5625, 0
    TextBox Discount txtDiscount Discount OutputFormat = Currency Detail 4.75, 0

Adding three Windows Forms with viewers to your project

To add three Windows Forms with viewers to your project

  1. Click on Project > Add Windows Form.
  2. Select Windows Form and rename it frmViewMain.
  3. Click Open.
  4. Drag the ActiveReports Viewer control onto the frmViewMain and set the Dock property to Fill.
  5. Click on Project > Add Windows Form.
  6. Select Windows Form and rename it frmViewDrillDown1.
  7. Click Open.
  8. Drag the ActiveReports Viewer control onto the frmViewDrillDown1 and set the Dock property to Fill.
  9. Click on Project > Add Windows Form.
  10. Select Windows Form and rename it frmViewDrillDown2.
  11. Click Open.
  12. Drag the ActiveReports Viewer control onto the frmViewDrillDown2 and set the Dock property to Fill.

Adding code to frmViewMain

To write the code to run rptMain in Visual Basic

To write the code to run rptMain in C#

To write the code to simulate drill down reporting in Visual Basic

To write the code to simulate drill down reporting in C#

Adding code to frmViewDrillDown1

To write the code in Visual Basic

To write the code in C#

Adding code to frmViewDrillDown2

To write the code in Visual Basic

To write the code in C#

Adding the code needed to set the hyperlink property for rptMain

To write the code in Visual Basic

To write the code in C#

Adding the code needed to set the hyperlink property for rptDrillDown1

To write the code in Visual Basic

To write the code in C#

Click in the Detail section of rptDrillDown1 to select the section. Click on the events icon in the Properties window to display available events for the section. Double-click BeforePrint. This creates an event-handling method for rptDrillDown1's Detail_BeforePrint event.

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

' Visual Basic
Private Sub Detail_BeforePrint(ByVal sender As Object, ByVal e As System.EventArgs) _
        Handles Detail.BeforePrint
Me.txtOrderID.HyperLink = Me.txtOrderID.Text
End Sub
//C#
private void Detail_BeforePrint(object sender, System.EventArgs eArgs)
{
this.txtOrderID.HyperLink = txtOrderID.Text;
}

Samples | Walkthroughs | OutputFormat Strings

 

 


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