ActiveReports 9
Reports with TableOfContents
Show AllShow All
Hide AllHide All

This walkthrough illustrates how to create a report that includes the TableOfContents (ToC) control and displays the document map on a report page. 

The TableOfContents control allows you to quickly navigate to desired data inside a report. You can use the TableOfContents control to embed the list of contents in the report body for printing and rendering, unlike the Document Map that is only available in the Viewers and cannot be rendered or printed.

This walkthrough is split into the following procedures:

When you complete this walkthrough you get a layout that looks similar to the following at design time and at runtime.

Design Time Layout

Runtime Layout

To add an ActiveReports to the Visual Studio project

  1. Create a new Visual Studio Windows Forms Application project.
  2. From the Project menu, select Add New Item.
  3. In the Add New Item dialog that appears, select ActiveReports 9 RDL Report and in the Name field, rename the file as ReportsWithToC.rdlx.
  4. Click the Add button to open a new RDL report.

See Adding an ActiveReport to a Project for information on adding different report layouts.

To connect the report to a data source

This walkthrough uses the Movies table from the Reels database. By default, in ActiveReports, the Reels.mdb file is located in the [User Documents folder]\GrapeCity Samples\ActiveReports 9\Data folder.

  1. In the Report Explorer, right-click the Data Sources node and select the Add Data Source option or select Data Source from the Add button.
  2. In the Report Data Source Dialog that appears, select the General page and in the Name field, enter a name like ReportData.
  3. On this page, create a connection to the Reels database. See Connect to a Data Source for information on connecting to a data source.

To add a dataset

  1. In the Report Explorer, right-click the data source node and select the Add Data Set option or select Data Set from the Add button.
  2. In the DataSet Dialog that appears, select the General page and enter the name of the dataset as MovieCatalog. This name appears as a child node to the data source icon in the Report Explorer.
  3. On the Query page of this dialog, in the Query field enter the following SQL query.
    SQL Query
    Copy Code
    SELECT Genre.GenreName, Movie.Title, Movie.YearReleased, Movie.UserRating, Movie.Country FROM Genre INNER JOIN (Movie INNER JOIN MovieGenres ON Movie.MovieID = MovieGenres.MovieID) ON Genre.GenreID = MovieGenres.GenreID ORDER BY YearReleased ASC
    
  4. Click the Validate DataSet icon at the top right hand corner above the Query box to validate the query.

  5. Click OK to close the dialog. Your data set and queried fields appear as nodes in the Report Explorer.

To create a layout for the report

  1. From the toolbox, drag the List control onto the design surface and in the Properties window, set the following properties.
    Property Name Property Value
    DataSetName MovieCatalog
    Location 0.25in, 1.875in
    Size 6in, 4in
    PageBreakAtStart True
  2. With the List data region selected, under the Properties window, click the Property dialog link to open the List dialog
  3. Go to the Detail Grouping page and on the General tab, under Group on, set the Expression field to =Fields!GenreName.Value.  
  4. Click OK to close the dialog
  5. In the Report Explorer, from the MovieCatalog dataset, drag and drop the GenreName field inside the List data region and in the Properties window, set the following properties.  
    Property Name Property Value
    Location 0.25in, 0.375in
    Font Normal, Arial, 12pt, Bold
    TextAlign Center
    Size 5.625in, 0.25in
    Label =Fields!GenreName.Value
    Note: Setting the control's Label property adds an entry of the control in the document map.
  6. From the toolbox, drag and drop the Table data region inside the List data region and in the Properties window, set the following properties. 
    Property Name Property Value
    Location 0.125in, 1in
    Size 6in, 0.75in
    DataSetName MovieCatalog
    BorderStyle Solid
    RepeatHeaderOnNewPage True
  7. In the Table data region, place your mouse over the cells of the table details row to display the field selection adorner.
  8. Click the adorner to show a list of available fields from the MovieCatalog dataset and add the following fields to the cells of the table details row.

    Cell Field
    Left Cell Title
    Middle Cell Country
    Right Cell UserRating
    This automatically places an expression in the details row and simultaneously places a static label in the header row of the same column.
    Tip: You can also directly drag fields from the Report Explorer onto the textbox cells of the Table data region.
  9. Select the table header row using the row handle to the left and in the Properties Window set the following properties. 
    Property Name Property Value
    Font > FontWeight Bold
    TextAlign Left
    BackgroundColor Silver
    BoderStyle Solid
  10. Select the table detail row using the row handle to the left, and in the Properties Window set the following properties.
    Property Name Property Value
    TextAlign Left
    BorderStyle Solid
  11. Right-click the table detail row using the row handle to the left, and select Insert Group...
  12. In the Table - Groups dialog that appears, on the General tab, under Group on, set the Expression field to =Fields!YearReleased.Value.
  13. Click OK to close the dialog.
  14. Select the textboxes inside the table group row using the CTRL key and left mouse button, right-click the selection and select Merge Cells.
  15. Select the merged cell and in the Properties window, set the following properties.
    Property Name Property Value
    Font Normal, Arial, 10pt, Bold
    HeadingLevel Heading 2
    Note: Setting the control's HeadingLevel property adds an entry of the control in the document map.
    TextAlign Center
    Value ="Movies Released in " & Fields !YearReleased.Value
  16. From the Visual Studio toolbox, drag a TableOfContents control onto the design surface and in the Properties window, set the following properties.  
    Property Name Property Value
    Location 0.25in, 0.5in
    Size 6in, 0.875in
    BorderStyle Solid

To configure the appearance of Table of Contents

  1. With the TableOfContents control selected, select the Levels (Collection) property and then click the ellipsis button that appears.
  2. In the LevelDesigner Collection Editor dialog that appears, under Members, use the Add button to add Level2 to the TableOfContents.
  3. Under Members, select Level1 and click the Property Pages button above the LevelDesigner Collection Editor properties grid.
  4. In the Level Properties dialog that appears, set the following properties.

    Properties

  5. Click OK to close the dialog.
  6. In the LevelDesigner Collection Editor, select the Level2 entry under Members and click the Property Pages button above the LevelDesigner Collection Editor Properties grid.
  7. In the Level Properties dialog that appears, set the Font > Weight property to Bold.
  8. Click OK to close the dialog.
  9. In the LevelDesigner Collection Editor, with Level2 selected under Members, in properties grid, set the Padding property to 20pt, 10pt, 0pt, 0pt and the DisplayPageNumber property to False.
  10. Click OK to close the LevelDesigner Collection Editor dialog.
  11. In the Report Explorer, select the Report node and in the Properties window set the following properties:

    Properties

To view the report

OR

See Also

Concepts

How To

 

 


Copyright © 2016 GrapeCity, inc. All rights reserved

Support Forum