ComponentOne FlexReport for WinForms
Subreports
Working with FlexReportDesigner > Working with Parameters > Subreports

Subreports are useful in displaying additional information about the data present in the main report. Just as you pass parameters to a report, you can also pass parameters to subreports and create connection between the data values in subreports.

For instance, you want to fetch data in subreports that are rendered side by side on a main report. The steps to attain such a scenario are as follows.

  1. Run C1FlexReportDesigner.exe application.
  2. Create a new report definition, main report, in an unbound mode.
  3. Create another report and bind it to Photos report available in the C1NWind.mdb.
  4. From the Insert tab, click Subreport field. All the available reports will be displayed.
  5. Drop two Subreport fields side by side.
  6. Add two parameters that will be passed one for each subreport.
  7. Set the name of parameters from Name property - 'prmLeftPlace' for parameter on left subreport and 'prmRightPlace' for parameter on right subreport.
  8. Add Data Source for parameters - set data provider and connection string. Write a Sql Statement that will be used to pass values to the parameters. For example, to select 'Place' from the 'Photos' report, the statement should be:
    select distinct Place from Photos order by Place
            
    
  9. Set AllowedValuesDefinition property for both the parameters - 
    1. Click the ellipsis button next to AllowedValuesDefinition.
    2. In the AllowedValuesDefinition Editor dialog box, select the From Data Source radio button.
    3. Select Data Source, Label, and Value for binding the data source to the parameter. 
  10. Set the prompt text from Prompt property for each of the parameter.
  11. Select Subreport -Photos- click Data tab
  12. Edit the data source and write the following Sql Statement:
    select distinct Place from Photos order by Place

  13. Select the main report and click the Subreport field on left. Click ellipsis next to ParameterValues.ParameterValuesCollection Editor appears. Set the Name and Value as shown.
  14. Similarly, set the Name - prmPlace and Value - prmRightPlace.Value for Subreport field on the right. In the design view the report should look similar to the following:
  15. Preview the report.

You can see two parameter prompts with a list of values (i.e. places), one for each subreport. Select the values and click Apply Parameters. Here, we have selected Chaumont for left subreport and Cote d'Azur for right subreport.