Conditionally Change a Control's Appearance
This tutorial describes how to conditionally change a control's appearance (e.g., make a Label's text red if its value exceeds a certain threshold). Thanks to the formatting rules feature, no scripts are required to complete this task, so you should not have to write any code.
To conditionally change a control's appearance, do the following.
Right-click the report and select Edit Formatting Rule Sheet... in the invoked context menu.
In the invoked Formatting Rule Sheet Editor, create a new formatting rule using the plus button, and then, click the ellipsis button for its Condition property.
In the invoked Expression Editor, define the required Boolean condition (which means that its result is returned as either true or false). This tutorial demonstrates how to format fields if the UnitPrice value is greater than 30.
To save the condition and close the dialog, click OK.
Return to the Formatting Rule Sheet Editor and define the formatting to be applied, e.g., specify the desired foreground color.
To save the changes and quit the dialog, click OK.
Finally, select the band or control to which the formatting rule should be applied (in this example, it is the Detail band), and select Edit Formatting Rules... in the context menu.
In the invoked Formatting Rules Editor, move the rule from left to right using the right arrow button so that you can apply the rule for this band.
If multiple rules are applied, it is possible to customize their precedence using the up and down arrow buttons. So, the rules are applied in the same order that they appear in the list, and the last rule in the list has the highest priority.
Switch your report to the Print Preview tab and view the result.