Conditionally Change a Control's Appearance

This document describes the steps needed 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 achieve this, so you shouldn't write any code.

To conditionally change a control's appearance, do the following.

  1. Create a new report and bind it to a data source.
  2. Switch to the Properties Panel, expand the Appearance category and then expand the Formatting Rules section. Add a new formatting rule by clicking the formatting-rules-editor-add button.

    eud-change-control-appearance-0

  3. Expand the newly added rule, specify its name and formatting options (e.g., Foreground Color). You can also specify the Data Source and Data Member properties. These properties define the list containing data fields that can participate in constructing the Boolean condition.

    eud-change-control-appearance-1

  4. Then, click the ellipsis button for the Condition property. In the invoked Expression Editor, define the required Boolean condition (which means that its result is returned as either true or false). In this tutorial, we will format fields if the UnitPrice value is greater than 30.

    eud-change-control-appearance-2

    To save the condition and close the dialog, click Save.

  5. A formatting rule can be applied to any number of report elements within the same report. To apply a rule to a control, select the required report control and enable the checkbox for the required rule.

    eud-change-control-appearance-3

    If multiple rules are applied, it is possible to customize their precedence by using the formatting-rules-editor-up and formatting-rules-editor-down 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 Preview mode and view the result.

eud-change-control-appearance-4

results matching ""

    No results matching ""