Conditionally hide bands

This procedure describes the steps to conditionally hide bands.

In this example, we will hide the Group Header and Detail bands when a grouping field meets a certain condition. Note that this procedure does not use scripts to accomplish this task.

For more information, see Report bands.

  1. Create a new report.
  2. Add a Group Header band to the report.
    To do this, right-click anywhere over the report's surface, and click Insert Band > GroupHeader.
  3. Drag a field that will be used as a grouping criteria from the Field List onto the created GroupHeader1 band.
    Hide bands
  4. Click the Smart tag of the GroupHeader1 band, and in the invoked actions list, click the browse button (...) in the Group Fields section.
    This opens the GroupField Collection Editor dialog box.

    Hide bands

  5. Click Add, to add a new grouping field, and set its Field Name property to the required field.
  6. Click OK to apply the settings and close the dialog box.
  7. Drag fields representing the general report's data onto the report's Detail band.
    Hide bands
  8. Select the Group Header band's strip, then in the Property Grid, click the Formatting Rules browse button.
  9. In the Formatting Rules Editor, click the Edit Rule Sheet button.
  10. In the Formatting Rule Sheet Editor, click the Add button, to create a new rule.
  11. Set the new properties Visible property to No, and for the Condition property, click the browse button (...).
  12. Construct the required Boolean expression to be met (for example, [ShipCountry] == 'Argentina'). Then click OK and Close to close the Formatting Rule Sheet Editor.
  13. In the Formatting Rules Editor, activate the new rule by moving it to the Applied Rules box.
    Repeat this step for the report's Detail band (click its Formatting Rules property's ellipsis button, and in the invoked dialog, apply the same rule to this band). If you do not do this, the Group Header band will not be displayed when the rule's condition is met while the detailed section of this group will still be visible.
  14. Switch to the Preview Tab to view the result.
    In the figure, you can see that there is no Argentina section in the report, while it's the first record in our database. So, the conditional formatting was applied properly.
    Hide bands