Using the Hyperlink property available on the following ActiveReports controls, you can add hyperlinks that connect to a Web page, open an e-mail, or jump to a bookmark.
- Label
- TextBox
- Picture
- OleObject

Note: When using the HtmlViewer, the RawHtml, the Flash Viewer or the Silverlight Viewer to display a report, you should indicate a full URL address (for example, "http://www.datadynamics.com") for the Hyperlink property.
To link to a Web page
- Click the control to select it.
- In the Properties window, set the HyperLink property to any valid URL.
To link to an e-mail address
- Click the control to select it.
- In the Properties window, set the HyperLink property to mailto: and any valid e-mail address.
To parse the URL out of a database field for a hyperlink
- Double-click the section where the control is located. This creates an event-handling method for the section's Format event.
- Add code to the Format event to
- Parse the URL out of the HomePage field
- Assign it to the HyperLink property of txtHomePage
- Remove the URL markers from the text displayed in txtHomePage
The following example shows what the code for the method looks like.
To write the code in Visual Basic.NET
| Visual Basic.NET code. Paste INSIDE the Format event. | Copy Code |
|---|---|
Dim iStart As Integer
Dim sHTML As String
If txtHomePage.Text <> "" Then
iStart = InStr(1, txtHomePage.Text, "#", CompareMethod.Text)
sHTML = Right(txtHomePage.Text, (Len(txtHomePage.Text) - iStart))
sHTML = Replace(sHTML, "#", "", 1, -1, CompareMethod.Text)
txtHomePage.HyperLink = sHTML
txtHomePage.Text = Replace(txtHomePage.Text, "#", "", 1, -1, CompareMethod.Text)
End If
| |
| C# code. Paste INSIDE the Format event. | Copy Code |
|---|---|
int iStart;
string sHTML;
if (txtHomePage.Text != "")
{
iStart = txtHomePage.Text.IndexOf("#",0);
sHTML = txtHomePage.Text.Substring(iStart, txtHomePage.Text.Length - iStart);
sHTML = sHTML.Replace("#", "");
txtHomePage.HyperLink = sHTML;
txtHomePage.Text = txtHomePage.Text.Replace("#", "");
}
| |
To create a hyperlink that jumps to a bookmark
- Double-click the section where the control is located. This creates an event-handling method for the section's Format event.
- Add code to the Format event to
- Parse the URL out of the HomePage field
- Assign it to the HyperLink property of txtHomePage
- Remove the URL markers from the text displayed in txtHomePage
The following example shows what the code for the method looks like.
To write the code in Visual Basic.NET
| Visual Basic.NET code. Paste JUST ABOVE the Format event. | Copy Code |
|---|---|
Public pBM As New BookmarksCollection() Dim iEntry As Integer | |
| Visual Basic.NET code. Paste INSIDE the Format event. | Copy Code |
|---|---|
Me.Detail1.AddBookmark(Me.txtCompanyName.Text) Me.txtEntry.HyperLink = "toc://" + pBM(iEntry - 1).Label Me.txtEntry.Text = pBM(iEntry - 1).Label Me.txtPage.Text = pBM(iEntry - 1).PageNumber | |
| C# code. Paste JUST ABOVE the Format event. | Copy Code |
|---|---|
public BookmarksCollection pBM = new BookmarksCollection(); int iEntry; | |
| C# code. Paste INSIDE the Format event. | Copy Code |
|---|---|
this.detail.AddBookmark(this.txtCompanyName.Text); this.txtEntry.HyperLink = "toc://" + pBM[iEntry - 1].Label; this.txtEntry.Text = pBM[iEntry - 1].Label; this.txtPage.Text = pBM[iEntry - 1].PageNumber.ToString(); | |
To display the page number of the bookmark in the table of contents
To write the code in Visual Basic
- At the top left of the code view for the report, click the drop-down arrow and select (YourReportName Events).
- At the top right of the code window, click the drop-down arrow and select FetchData. This creates an event-handling method for the report's FetchData event.
- Add code to the handler to retrieve information to populate the report fields.
The following example shows what the code for the method looks like.
| Visual Basic.NET code. Paste INSIDE the FetchData event. | Copy Code |
|---|---|
If iEntry > pBM.Count - 1 Then
eArgs.EOF = True
Else
eArgs.EOF = False
iEntry += 1
End If
| |
- Back in design view, click in the gray area below the report to select it.
- Click the events icon in the Properties window to display available events for the report.
- Double-click FetchData. This creates an event-handling method for the report's FetchData event.
- Add code to the handler to retrieve information to populate the report fields.
The following example shows what the code for the method looks like.
| C# code. Paste INSIDE the FetchData event. | Copy Code |
|---|---|
if (iEntry > pBM.Count - 1)
{
eArgs.EOF = true;
}
else
{
eArgs.EOF = false;
iEntry += 1;
}
| |
Walkthroughs
Hyperlinks for Simulated Drill-Down Reporting
Related Sections
Getting Started
Hide All