| ActiveReports 9 > ActiveReports User Guide > How To > Section Report How To > Add Hyperlinks |
In a section report, you can add hyperlinks in a report using the Hyperlink property available with the following controls:
You can add hyperlinks that connect to a Web page, open an e-mail, or jump to a bookmark.
![]() |
Note: Specify the full URL address (for example, "http://www.grapecity.com") for the Hyperlink property to avoid broken links while viewing reports. |
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 textBox1.Text <> "" Then
iStart = InStr(1, textBox1.Text, "#", CompareMethod.Text)
sHTML = Right(textBox1.Text, (Len(textBox1.Text) - iStart))
sHTML = Replace(sHTML, "#", "", 1, -1, CompareMethod.Text)
textBox1.HyperLink = sHTML
textBox1.Text = Replace(textBox1.Text, "#", "", 1, -1, CompareMethod.Text)
End If
|
|
To write the code in C#
| C# code. Paste INSIDE the Format event. |
Copy Code
|
|---|---|
int iStart;
string sHTML;
if (textBox1.Text != "")
{
iStart = textBox1.Text.IndexOf("#",0);
sHTML = textBox1.Text.Substring(iStart, textBox1.Text.Length - iStart);
sHTML = sHTML.Replace("#", "");
textBox1.HyperLink = sHTML;
textBox1.Text = textBox1.Text.Replace("#", "");
}
|
|
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.textBox1.Text) Me.txtEntry.HyperLink = "toc://" + pBM(iEntry - 1).Label Me.txtEntry.Text = pBM(iEntry - 1).Label Me.txtPage.Text = pBM(iEntry - 1).PageNumber |
|
To write the code in C#
| 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.textBox.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
The following example shows what the code for the method looks like.
To write the code in Visual Basic
| 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
|
|
To write the code in C#
| C# code. Paste INSIDE the FetchData event. |
Copy Code
|
|---|---|
if (iEntry > pBM.Count - 1)
{
eArgs.EOF = true;
}
else
{
eArgs.EOF = false;
iEntry += 1;
}
|
|