This document describes how to toggle the visibility of a report band in Print Preview based on a certain logical condition.
See Conditionally Change a Band's Visibility to learn about the alternative approach to solving this task.
See Data Binding Modes to learn more about the available binding modes.
The report created in this tutorial displays the sub-band by selecting the corresponding parameter value in Print Preview:
Do the following to make the report display an additional header based on the selected filtering criteria:
Add a SubBand to the Report Header band. To do this, right-click the Report Header band and choose Add Sub-Band in the invoked dialog.
Drop XRLabel controls onto the Report Header band and its sub-band and specify the labels' text as shown below.
Select the created sub-band and click its smart tag. In the invoked actions list, click the ellipsis button for the XRControl.FormattingRules property.
Then, in the invoked Formatting Rules Editor, click the Edit Rule Sheet... button.
In the invoked Formatting Rule Sheet Editor, click to create a new formatting rule. For this rule, set the Visible property to false.
Then, locate the FormattingRule.Condition property and click its ellipsis button. The Condition Editor will appear.
In this editor, define a Boolean expression for the rule (e.g., [Discontinued] == False). This means that the Discontinued data field should be false for the appropriate control to be hidden.
Click OK to save the changes and close the dialog. Then, click Close to quit the Formatting Rule Sheet Editor.
Now, in the Formatting Rules Editor, you can see the created rule (named formattingRule1), which should be moved to the list of active rules at the right using the arrow buttons in the middle of the dialog.
It is also possible to customize the precedence of formatting rules by using the up and down arrow buttons at the right of the dialog. The rules are applied in the same order they are on the list, and the last rule on the list has the highest priority.
Switch to the Field List, right-click the Parameters section, and choose Add Parameter. In the invoked window, set the name of the created parameter and choose its type.
In the invoked FilterString Editor, construct an expression where the Discounted data field is compared with the parameterDiscounted parameter. To access the parameter, click the icon on the right until it turns into a question mark.