ActiveReports can display bookmarks and nested bookmarks in the viewer's table of contents for fields, groups, subreports. You can also add special bookmarks at run time.
This code uses the same controls used in the Basic Data Bound Reports walkthrough
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 Detail Format event. |
Copy Code |
---|---|
Me.Detail1.AddBookmark(txtProductName1.text) |
To write the code in C#
C# code. Paste INSIDE the Detail Format event. |
Copy Code |
---|---|
detail.AddBookmark(txtProductName1.Text); |
This code uses fields from the Group On Unbound Fields walkthrough.
The following example shows what the code to set up leveled or nested Bookmarks looks like.
To write the code in Visual Basic.NET
Visual Basic.NET code. Paste INSIDE the Detail Format event. |
Copy Code |
---|---|
Me.Detail1.AddBookmark(txtCategoryName.Text + "\" + txtProductName.Text) |
To write the code in C#
C# code. Paste INSIDE the Detail Format event. |
Copy Code |
---|---|
detail.AddBookmark(txtCategoryName.Text + "\\" + txtProductName.Text); |
The following example shows what the code for the detail section looks like.
To write the code in Visual Basic.NET
Visual Basic.NET code. Paste INSIDE the Detail Format event. |
Copy Code |
---|---|
Me.Detail1.AddBookmark(txtCountry1.Text + "\" + txtCity1.Text + "\" + txtCompanyName1.Text) |
To write the code in C#
C# code. Paste INSIDE the Detail Format event. |
Copy Code |
---|---|
this.detail.AddBookmark(txtCountry1.Text + "\\" + txtCity1.Text + "\\" + txtCompanyName1.Text); |
The following example shows what the code for the group header looks like.
To write the code in Visual Basic.NET
Visual Basic.NET code. Paste INSIDE the Group Header Format event. |
Copy Code |
---|---|
Me.GroupHeader1.AddBookmark(txtCountry1.Text) |
To write the code in C#
C# code. Paste INSIDE the Group Header Format event. |
Copy Code |
---|---|
this.groupHeader1.AddBookmark(txtCountry1.Text); |
This code uses the same controls as those found in the Subreports with Run-Time Data Sources walkthrough.
The following example shows what the code for the method looks like for the main report.
To write the code in Visual Basic.NET
Visual Basic.NET code. Paste INSIDE the Detail Format event of the main report. |
Copy Code |
---|---|
Me.Detail1.AddBookmark(txtCategoryName1.Text) |
To write the code in C#
C# code. Paste INSIDE the Detail Format event of the main report. |
Copy Code |
---|---|
detail1.AddBookmark(txtEmployeeID1.Text); |
The following example shows what the code for the method looks like for the subreport.
To write the code in Visual Basic.NET
Visual Basic.NET code. Paste INSIDE the Detail Format event of the subreport. |
Copy Code |
---|---|
Me.Detail1.AddBookmark(CType(Me.ParentReport.Sections("Detail1").Controls("txtCategoryName1"), TextBox).Text + "\" + Me.txtProductName.Text) |
To write the code in C#
C# code. Paste INSIDE the Detail Format event of the subreport. |
Copy Code |
---|---|
this.detail1.AddBookmark(((TextBox)(this.ParentReport.Sections["ghEmployees"].Controls["txtEmployeeID1"])).Text + "\\" + this.txtCompanyName1.Text); |
To create and add special bookmarks to the bookmarks collection at run time, add the bookmarks to the report document's pages collection.
Caution: Keep in mind that the pages collection does not exist until after the report runs, so use this code in the ReportEnd event or in form code after the report has run. |
To write the code in Visual Basic.NET
The following example shows what the code for the method looks like.
Visual Basic.NET code. Paste INSIDE the ReportEnd event. |
Copy Code |
---|---|
Me.Document.Pages(0).AddBookmark("New Bookmark", 1) |
To write the code in C#
The following example shows what the code for the method looks like.
C# code. Paste INSIDE the ReportEnd event. |
Copy Code |
---|---|
this.Document.Pages[0].AddBookmark("New Bookmark", 1); |