Glossary Item Box
ActiveReports allows you to use the hyperlink property to reference back to the bookmarks collection.
This walkthrough illustrates how to add to add hyperlinks to a report which reference 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 (Nwind.mdb).
When you have completed this walkthrough, you will have a report that looks similar to the following.
To add two ActiveReports to a Visual Studio project
To connect the report to a data source
To add controls to the reports
Control | Name | Text/Caption | 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 |
Control | DataField | Name | Text/Caption | Location |
---|---|---|---|---|
TextBox | CompanyName | txtCompanyName | Company Name | 0, 0 |
TextBox | ContactName | txtContactName | Contact Name | 1.562, 0 |
TextBox | Phone | txtPhone | Phone | 2.687, 0 |
TextBox | Fax | txtFax | Fax | 3.812, 0 |
TextBox | HomePage | txtHomePage | Home Page | 4.854, 0 |
Control | Name | Text/Caption | Misc Details | 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 |
Control | Name | Text/Caption | Location |
---|---|---|---|
Label | lblDirectory | Directory | 0.5, 0 |
Label | lblCompanyName | CompanyName | 1.125, 0.437 |
Label | lblPage | Page | 3.312, 0.437 |
Line | Line1 | (Empty string) | X1 = 0
Y1 = 0.697 X2 = 6.5 Y2 = 0.697 |
Control | Name | Text/Caption | Location |
---|---|---|---|
TextBox | txtEntry | Company Name | 1.125, 0 |
TextBox | txtPage | Page | 3.312, 0 |
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_Format(ByVal sender As Object, ByVal e As System.EventArgs) Handles _ Detail.Format Me.Detail.AddBookmark(Me.txtCompanyName.Text) 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 End Sub
//C# private void Detail_Format(object sender, System.EventArgs eArgs) { this.Detail.AddBookmark(this.txtCompanyName.Text); int iStart; string sHTML; if (txtHomePage.Text != "") { iStart = txtHomePage.Text.IndexOf("#",0);//[1, txtHomePage.Text, "#", CompareMethod.Text); sHTML = txtHomePage.Text.Substring(iStart, txtHomePage.Text.Length - iStart); sHTML = sHTML.Replace("#", ""); txtHomePage.HyperLink = sHTML; txtHomePage.Text = txtHomePage.Text.Replace("#", ""); } }
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 rptMain_ReportEnd(ByVal sender As Object, ByVal e As System.EventArgs) _ Handles MyBase.ReportEnd Dim rpt As New rptBookmarks() rpt.pBM = Me.Document.Bookmarks rpt.Run() Me.Document.Pages.InsertRange(Me.Document.Pages.Count, rpt.Document.Pages) End Sub
//C# private void rptMain_ReportEnd(object sender, System.EventArgs eArgs) { rptBookmarks rpt = new rptBookmarks(); rpt.pBM = this.Document.Bookmarks; rpt.Run(); this.Document.Pages.InsertRange(this.Document.Pages.Count, rpt.Document.Pages); }
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 Public pBM As New BookmarksCollection() Private Sub Detail_Format(ByVal sender As Object, ByVal e As System.EventArgs) Handles _ Detail.Format Dim iEntry As Integer Me.txtEntry.HyperLink = "toc://" + pBM(iEntry - 1).Label Me.txtEntry.Text = pBM(iEntry - 1).Label Me.txtPage.Text = pBM(iEntry - 1).PageNumber End Sub
//C# public BookmarksCollection pBM = new BookmarksCollection(); private void Detail_Format(object sender, System.EventArgs eArgs) { int iEntry; this.txtEntry.HyperLink = "toc://" + pBM[iEntry - 1].Label; this.txtEntry.Text = pBM[iEntry - 1].Label; this.txtPage.Text = pBM[iEntry - 1].PageNumber.ToString(); }
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 rptBookmarks_FetchData(ByVal sender As Object, ByVal eArgs As DataDynamics _ .ActiveReports.ActiveReport.FetchEventArgs) Handles MyBase.FetchData Dim iEntry As Integer If iEntry > pBM.Count - 1 Then eArgs.EOF = True Else eArgs.EOF = False iEntry += 1 End If End Sub
//C# int iEntry; private void rptBookmarks_FetchData(object sender, DataDynamics.ActiveReports .ActiveReport.FetchEventArgs eArgs) { int iEntry = 0; if (iEntry > pBM.Count - 1) { eArgs.EOF = true; } else { eArgs.EOF = false; iEntry += 1; } }
To view the report
See Also |
Samples | Walkthroughs | GroupKeepTogether enumeration
Copyright © 2004-2005 Data Dynamics, Ltd. All rights reserved.