Glossary Item Box
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.

To add three ActiveReports to a Visual Studio project
To connect the report to a data source
To connect the report to a data source
To connect the report to a data source
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.
To add controls to the reports
| 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 |
| 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 |
| 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 |
To add three Windows Forms with viewers to your project
To write the code to run rptMain in Visual Basic
To write the code to run rptMain in C#
The following example shows what the code for the method looks like.
' Visual Basic
Private Sub Form1_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles _ MyBase.Load
Dim rpt As New rptMain()
Viewer1.Document = rpt.Document
rpt.Run()
End Sub
//C#
private void Form1_Load(object sender, System.EventArgs e)
{
rptMain rpt = new rptMain();
this.viewer1.Document = rpt.Document;
rpt.Run();
}
To write the code to simulate drill down reporting in Visual Basic
To write the code to simulate drill down reporting in C#
The following example shows what the code for the method looks like.
' Visual Basic
Private Sub Viewer1_HyperLink(ByVal sender As Object, ByVal e As DataDynamics.ActiveReports _
.Viewer.HyperLinkEventArgs) Handles Viewer1.HyperLink
Dim rpt2 As New rptDrillDown1()
Dim frm2 As New frmViewDrillDown1()
rpt2.Parameters("customerID").Value = e.HyperLink.ToString
Console.WriteLine(rpt2.ds.SQL.ToString)
rpt2.Run()
frm2.My_Viewer.Document = rpt2.Document
frm2.ShowDialog(Me)
End Sub
//C#
private void viewer1_HyperLink(object sender, DataDynamics.ActiveReports.Viewer
.HyperLinkEventArgs e)
{
rptDrillDown1 rpt2 = new rptDrillDown1();
frmViewDrillDown1 frm2 = new frmViewDrillDown1();
rpt2.Parameters["customerID"].Value = e.HyperLink.ToString();
rpt2.Run();
frm2.My_Viewer.Document = rpt2.Document;
frm2.ShowDialog(this);
}
To write the code in Visual Basic
To write the code in C#
The following example shows what the code for the method looks like.
' Visual Basic
Private Sub Viewer1_HyperLink(ByVal sender As Object, ByVal e As DataDynamics _
.ActiveReports.Viewer.HyperLinkEventArgs) Handles Viewer1.HyperLink
Dim rpt3 As New rptDrillDown2()
Dim frm3 As New frmViewDrillDown2()
rpt3.Parameters("orderID").Value = e.HyperLink.ToString
Console.WriteLine(rpt3.ds.SQL.ToString)
rpt3.Run()
frm3.Viewer1.Document = rpt3.Document
frm3.ShowDialog(Me)
End Sub
Friend ReadOnly Property My_Viewer() As DataDynamics.ActiveReports.Viewer.Viewer
Get
Return Me.Viewer1
End Get
End Property
//C#
private void viewer1_HyperLink(object sender, DataDynamics.ActiveReports.Viewer
.HyperLinkEventArgs e)
{
rptDrillDown2 rpt3 = new rptDrillDown2();
frmViewDrillDown2 frm3 = new frmViewDrillDown2();
rpt3.Parameters["orderID"].Value = e.HyperLink.ToString();
Console.WriteLine(rpt3.ds.SQL.ToString());
rpt3.Run();
frm3.My_Viewer.Document = rpt3.Document;
frm3.ShowDialog(this);
}
internal DataDynamics.ActiveReports.Viewer.Viewer My_Viewer
{
get
{
return this.viewer1;
}
}
To write the code in Visual Basic
To write the code in C#
The following example shows what the code for the method looks like.
' Visual Basic
Friend ReadOnly Property My_Viewer() As DataDynamics _
.ActiveReports.Viewer.Viewer
Get
Return Me.Viewer1
End Get
End Property
//C#
internal DataDynamics.ActiveReports.Viewer.Viewer My_Viewer
{
get
{
return this.viewer1;
}
}
To write the code in Visual Basic
To write the code in C#
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.txtCustomerID.HyperLink = Me.txtCustomerID.Text
End Sub
//C#
private void Detail_BeforePrint(object sender, System.EventArgs eArgs)
{
this.txtCustomerID.HyperLink = this.txtCustomerID.Text;
}
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;
}
| See Also |
Samples | Walkthroughs | OutputFormat Strings
Copyright © 2004-2005 Data Dynamics, Ltd. All rights reserved.