This document describes how to change a report band's visibility in Print Preview based on a specific logical condition.
See Conditionally Change a Band's Visibility to learn about the legacy approach to solving this task.
See Data Binding Modes to learn more about the available binding modes.
After you bound your report to data and provided content to the report's detail band, the report can display an additional header based on the selected filtering criteria.
Right-click the report's surface and add a report header.
Right-click the report header area and create a sub-band, which is the report header's functional copy.
Add two labels to the created bands, providing content for the two report header copies.
Select the sub-band and switch to the Visual Studio property grid. Switch to its Expressions section and click the Visible property's ellipsis button (you can find it under the BeforePrint event's category if you are using the ExpressionsAdvanced binding mode).
This invokes the Expression Editor where you can specify the required visibility expression. For example:
The expression above makes the Visible property return True or False values based on the Discontinued data field's value.
Switch to the Field List, right-click the Parameters section and add a new report parameter.
Specify the parameter's description displayed in Print Preview and set its type to Boolean.
Invoke the report's smart tag and click the XtraReportBase.FilterString property's ellipsis button.
This invokes the FilterString Editor where you can specify the required filter criteria and a reference to the created parameter.
When switching to Print Preview, the report can display the sub-band by selecting the corresponding parameter value: