ActiveReports 14 .NET Edition
ActiveReports 14 User Guide / Samples and Walkthroughs / Walkthroughs / Page Report/RDL Report Walkthroughs / Preview / Reports with TableOfContents
In This Topic
    Reports with TableOfContents
    In This Topic

    This walkthrough illustrates how to create a report that includes the Table of Contents (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.

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

    Design-Time Layout

    Report with bookmark at design time

    Report with bookmark at design time

    Run-Time Layout

    Report with bookmark at run time

    Report with bookmark at run time

    Report with bookmark at run time

    Report with bookmark at run time

    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 14 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 Quick Start 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. The Reels.mdb file can be downloaded from GitHub: ..\Samples14\Data\Reels.mdb.

    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.
      Adding a datasource
    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.
      Validate DataSet icon
    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

      Note: Applicable for RDL reports only.

    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

      Property Name Property Value
      Font > Size 14
      Font > Weight Bold
      Color DarkBlue
      Padding > Left 10pt
      Padding > Top 10pt
      Padding > Right 10pt
      Padding > Bottom 10pt
      Fill character .
    5. In the LevelDesigner Collection Editor, select the Level2 entry under Members and click the Property Pages button above the LevelDesigner Collection Editor Properties grid.
    6. In the Level Properties dialog that appears, set the following properties.

      Properties

      Property Name Property Value
      Font > Weight Bold
      Padding > Left 20pt
      Padding > Top 10pt
      Padding > Right 0pt
      Padding > Bottom 0pt
      DisplayPageNumber False
        
    7. Click OK to close the LevelDesigner Collection Editor dialog.
    8. In the Report Explorer, select the Report node and in the Properties window set the following properties:

      Properties

      Property Name Property Value
      DocumentMap > Source Labels and Headings
      DocumentMap > NumberingStyle 1, 2, 3, 4, 5

    To view the report

    OR

    See Also