Data Dynamics Reports Online Help
Walkthrough: BandedList Data Region
See Also Support Forum
User Guide > Samples and Walkthroughs > Walkthroughs > Walkthrough: BandedList Data Region

Glossary Item Box

You can create a freeform report with groupings in minutes using the Data Dynamics Reports BandedList control.

This walkthrough illustrates how to create a grouped banded list report. 

The walkthrough is split up into the following activities:

To complete the walkthrough, you must have access to the Reels sample database included with this installation.

When you are finished you will have a report that looks similar to the following.

Creating a Data Dynamics Report

To create a report in Visual Studio

  1. Create a new project in Visual Studio.
  2. From the Visual Studio Project menu, select Add New Item.
  3. In the Categories pane, select Data Dynamics Reports.
  4. In the Templates pane, select Report and name the report MovieDetails.rdlx.
  5. Click Add in Visual Studio 2005. 

Connecting the report to a data source

To connect the report to a data source

  1. If the Data Explorer is not in view, from the View menu, select Other Windows, then Data Dynamics Reports Data Explorer (at the bottom).
  2. Click the Add icon and select the Data Source... option.
  3. In the Report DataSource smart panel that appears, select the General page.
  4. Change the Name to Reels.
  5. Select the Shared Reference checkbox.

  6. Click the Browse button and select ReelsDataSource.rdsx, which is located in C:\My Documents\Data Dynamics\Reports\build number\Samples\Reels.
    Note: In Windows Vista, the path is C:\User\your name\Documents\Data Dynamics\Reports\build number\Samples\Reels\.
  7. Click the Accept button in the lower right corner to close the smart panel and see Reels appear in the Data Explorer.

Adding a dataset

To add a dataset

  1. Click the Add icon and select the Data Set... option.
  2. In the DataSet smart panel that appears, select the General page.
  3. Change the Name to Movies.
  4. On the Query page, change the Command Type to TableDirect and enter the "Movie" table into the Query text box.
     
  5. Click the Validate icon to validate the table and to populate the Fields list.
  6. Click the Accept button in the lower right corner to close the smart panel and see Movies and all of the fields in the table appear in the Data Explorer.

Adding a BandedList with Nested Grouping to the Report

To add a BandedList with nested grouping

  1. From the toolbox, drag a BandedList data region onto the body of the report. The banded list automatically spreads from the left edge to the right edge of the report body and contains a header, detail, and footer band.
  2. With the banded list selected in the combo box above the property grid, set the DataSetName property to Movies. This makes it easier to add groupings to the list because it populates the Group on Expression box with fields.
    Note: To select the banded list, click inside any band in the list and click the four-way arrow that appears at the top left of the control.

  3. Right-click inside the banded list and select Footer. This removes the footer band which we will not be using, and eliminates white space.
  4. Right-click inside the banded list and select Insert Group. This adds a group header between the BandedList header and the detail section, and a group footer below the detail section, and opens the Groups smart panel.
  5. In the Groups smart panel:
    • Drop down the list of expressions in the Group on Expression box and select
      =Fields!YearReleased.Value
      to group the movies based on the year in which they were released.
    • Change the Name to Year.
    • Clear the Include group footer checkbox since we won't be using it.
  6. Click the Add icon. This adds a second group header above the first, and a group footer below the detail section.
  7. Still in the Groups smart panel:
    • Select the newly added group in the list of groups.
    • Drop down the list of expressions in the Group on Expression box and select
      =Fields!MPAA.Value
      to group the movies based on the rating (i.e. G, PG, et cetera).
    • Change the Name to MPAA.
    • Clear the Include group footer checkbox since we won't be using it.
    • Click the Accept button in the lower right corner to close the smart panel and accept the changes.

Adding Report Items to the BandedList

To add report items to the BandedList

  1. From the toolbox, drag a TextBox report item onto the topmost band (BandedList1_Header).
    • Set the BackgroundColor property to Gray.
    • Set the Color property to White.
    • Expand the Font property and set its sub-properties to:
      • FontSize 14pt
      • FontWeight Bold
    • Set the Location property to 0in, 0in.
    • Set the Size property to 6.5in, 0.25in.
    • Set the TextAlign property to Center.
    • Set the Value property to Movie Details to create a static label.
  2. Click the BandedList1_Header band adorner (the grey bar along the top of the band) to select it, and in the property grid, change the RepeatOnNewPage property to True. This ensures that the label appears at the top of each page.
  3. Set the Height property of the header band to 0.25in.
  4. If the Data Explorer is not in view, from the View menu, select Other Windows, then Data Dynamics Reports Data Explorer (at the bottom).
  5. From the Data Explorer, drag the YearReleased field into the second band (Year_Header) of the banded list.
    • Set the BackgroundColor property to DarkGray.
    • Expand the Font property and set its sub-property FontWeight to Bold.
    • Set the Location property to 0in, 0in.
    • Set the Size property to 6.5in, 0.25in.
    • Set the TextAlign property to Left.
    • Change the Value property expression from the Sum aggregate to the First aggregate to display the first year released for each group. (A summary of the YearReleased field would not be very useful.)
  6. Click the Year_Header band adorner (the grey bar along the top of the band) to select it, and in the property grid, set the Height property of the header band to 0.25in.
  7. Drag the MPAA field into the third band (MPAA_Header).
    • Set the BackgroundColor property to Silver.
    • Set the BorderColor property to Gray and the BorderStyle property to Solid.
    • Expand the Font property and set its sub-property FontWeight to Bold.
    • Set the Location property to 0in, 0in.
    • Set the Size property to 6.5in, 0.25in.
    • Note that the Value property is automatically set to an expression using the First aggregate. This displays the movie rating for each group.
  8. Click the MPAA_Header band adorner (the grey bar along the top of the band) to select it, and in the property grid, set the Height property of the header band to 0.25in.
  9. Click inside the detail band to select it and set its Height property to 1.2in.
  10. Drag the following six fields onto the detail band and set their properties as indicated.
    Field Location Size Formatting
    Title 0in, 0.25in 3.75in, 0.25in
    Country 1.25in, 0.5in 1in, 0.25in
    Language 1.25in, 0.75in 1in, 0.25in
    Length 5.375in, 0in 1in, 0.25in TextAlign = Left
    UserRating 5.375in, 0.5in 1in, 0.25in TextAlign = Left
    IsColor 5.375in, 0.75in 1in, 0.25in
  11. Once you've arranged the fields, select the IsColor field and change the Value property to the following expression so that instead of "True" or "False," it will read "Color" or "Black and White."
    =Iif(Fields!IsColor.Value=True, "Color", "Black and White")
  12. Drag six TextBox report items onto the detail band and set  their properties as indicated.
    Value Location Size Formatting
    Movie Title: 0in, 0in 1in, 0.25in FontWeight = Bold
    Country of origin: 0in, 0.5in 1.25in, 0.25in FontWeight = Bold
    Language: 0in, 0.75in 1in, 0.25in FontWeight = Bold
    Length: 4.25in, 0in 1in, 0.25in FontWeight = Bold; TextAlign = Right
    User Rating: 4.25in, 0.5in 1in, 0.25in FontWeight = Bold; TextAlign = Right
    Format: 4.25in, 0.75in 1in, 0.25in FontWeight = Bold; TextAlign = Right
  13. Draw a Line report item onto the detail band below all of the text boxes.
    • Set the LineColor property to Gray.
    • Set the LineWidth property to 3pt.
    • Set the Location property to 0in, 1.12in.
    • Set the EndPoint property to 6.5in, 1.12in.
  14. From the File menu, select Save.

Viewing the report

Any report designed with Data Dynamics Reports can be opened in the included Data Dynamics Reports Viewer application or you can view it at design time.

To view the report at design time

  1. Click the Preview tab of the report designer.

To view the report at run time

  1. Add the ReportPreview control to your Visual Studio toolbox and drop it onto your Windows form.
  2. Set the Dock property of ReportPreview1 to Fill so that it will automatically resize if the form is resized at run time.
  3. Double-click the viewer to go to the Load event and use code like the following.
    'Visual Basic.NET 
    Dim rpt As New System.IO.FileInfo(Application.StartupPath & "..\\..\\MovieDetails.rdlx") 
    Me.ReportPreview1.OpenReport(rpt)
    //C# 
    System.IO.FileInfo rpt = new System.IO.FileInfo(Application.StartupPath + @"..\..\..\MovieDetails.rdlx"); 
    this.reportPreview1.OpenReport(rpt);
  4. Run the project.

See Also

©2010. GrapeCity, inc. All Rights Reserved.