This tutorial describes the steps to conditionally hide bands. In this example, we will hide the Group Headerand Detailbands, if a grouping field meets a certain condition. Note that no scriptsare required to accomplish this task.
-
Add a Group Header bandto the report.
For this, right-click anywhere over the report's surface, and in the invoked Context Menu, point to Insert Bandand click GroupHeader.
-
Drop a field which will be used as a grouping criteria, from the Field Listonto the created GroupHeader1band.
-
Click the Smart Tagof the GroupHeader1band, and in the invoked actions list, click the ellipsis button in the Group Fieldssection. The GroupField Collection Editordialog will appear.
In this dialog, click Add, to add a new grouping field, and set its Field Nameproperty to the required field.
To apply the settings and close the dialog, click OK.
-
Drop fields, representing the general report's data onto the report's Detail band.
-
Now, select the Group Header band's strip, and in the Property Grid, locate the Formatting Rulesproperty, and click its ellipsis button.
In the invoked Formatting Rules Editor, click the Edit Rule Sheet...button.
-
In the invoked Formatting Rule Sheet Editor, click the button, to create a new rule. Then, set its Visibleproperty to No, and for the Conditionproperty, click the ellipsis button.
-
Now, construct the required booleanexpression to be met (e.g. [ShipCountry] == 'Argentina'), and click OK.
Then, click Close, to quit the Formatting Rule Sheet Editor.
-
Finally, in the Formatting Rules Editor, move the created rule to the dialog's right section ( Applied Rules) for the rule to become active.
And, repeat this step for the report's Detail band (e.g. click its Formatting Rulesproperty's ellipsis button, and in the invoked dialog, make the same rule applied to this band, as well). Otherwise, only 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.
Switch to the Preview Tab, and view the result. In our example, you can see that there is no Argentinasection in the report, while it's the first record in our database. So, the conditional formatting was applied properly.
See Also