ActiveReports 6 Online Help
Add Bookmarks
See Also Send comments on this topic.
ActiveReports 6 > ActiveReports User Guide > How To > Add Bookmarks

Glossary Item Box

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.

To set up basic bookmarks

This code uses the same controls used in the Basic Data Bound Reports walkthrough

  1. Double-click on the detail section of the report. This creates an event-handling method for the report's Detail Format event.
  2. Add code to the handler to set up bookmarks.

The following example shows what the code for the method looks like.

ShowTo write the code in Visual Basic.NET

Visual Basic.NET code. Paste INSIDE the Detail Format event. Copy Code
Me.Detail1.AddBookmark(txtProductName1.text)

ShowTo write the code in C#

C# code. Paste INSIDE the Detail Format event. Copy Code
detail.AddBookmark(txtProductName1.Text);

To set up leveled or nested bookmarks

This code uses fields from the Group On Unbound Fields walkthrough.

  1. Double-click on the detail section of the report. This creates an event-handling method for the report's Detail Format event.
  2. Add code to the handler to set up bookmarks.

The following example shows what the code to set up leveled or nested Bookmarks looks like.

ShowTo 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)

ShowTo write the code in C#

C# code. Paste INSIDE the Detail Format event. Copy Code
detail.AddBookmark(txtCategoryName.Text + "\\" + txtProductName.Text);

To nest grandchild bookmarks and use bookmarks in grouping

  1. Double-click in the Detail section of the report. This creates an event-handling method for the report's Detail_Format event.
  2. Add code to the handler to set up a bookmark for each city and nest city bookmarks within each country, and company bookmarks in each city.

The following example shows what the code for the detail section looks like.

ShowTo 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)

ShowTo write the code in C#

C# code. Paste INSIDE the Detail Format event. Copy Code
this.detail.AddBookmark(txtCountry1.Text + "\\" + txtCity1.Text + "\\" + txtCompanyName1.Text);
  1. Double-click in the Group Header section of the report. This creates an event-handling method for the report's Group Header Format event.
  2. Add code to the handler to set up a bookmark for each instance of the country group.

The following example shows what the code for the group header looks like.

ShowTo 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)

ShowTo write the code in C#

C# code. Paste INSIDE the Group Header Format event. Copy Code
this.groupHeader1.AddBookmark(txtCountry1.Text);

To combine parent report and subreport bookmarks

This code uses the same controls as those found in the Subreports with Run-Time Data Sources walkthrough.

  1. Double-click in the Detail section of the main report to create an event-handling method for the report's Detail Format event.
  2. Add code to the handler to create a bookmark for each instance of the CategoryName field in the main report.

The following example shows what the code for the method looks like for the main report.

ShowTo 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)

ShowTo write the code in C#

C# code. Paste INSIDE the Detail Format event of the main report. Copy Code
detail1.AddBookmark(txtEmployeeID1.Text);
  1. Double-click in the Detail section of the subreport to create an event-handling method for the report's Detail Format event.
  2. Add code to the handler to create a bookmark for each instance of the CategoryName field in the subreport.

The following example shows what the code for the method looks like for the subreport.

ShowTo 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)

ShowTo 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 preview the report and Bookmarks Collection in the designer

  1. Click the Preview tab at the bottom of the designer.
  2. Click the Table of Contents icon to view the Bookmarks collection.


To view a report's bookmarks in the viewer

  1. Add the ActiveReports viewer control to your Windows form.
  2. Add code to display the report document in the viewer. See Viewing Reports for help.
  3. Press F5 to run the report.
  4. Click the Table of Contents icon to view the Bookmarks collection.


To add special bookmarks at run time

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.

ShowTo write the code in Visual Basic.NET

  1. In design view of the report, drop down the field at the top left of the code view and select (rptYourReportName Events).
  2. Drop down the field at the top right of the code view and select ReportEnd. This creates an event-handling method for ReportEnd event.
  3. Add code to the handler to add a bookmark.

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)

ShowTo write the code in C#

  1. Click in the gray area below the report to select it.
  2. Click the events icon in the Properties Window to display available events for the report.
  3. Double-click ReportEnd. This creates an event-handling method for the ReportEnd event.
  4. Add code to the handler to add a bookmark.

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);

See Also

Getting Started
Viewing Reports

Related Sections
Concepts
Walkthroughs