Conditionally Change a Control's Appearance

This document describes how to change a report control's appearance based on a specific condition.

Note

You can use this approach to conditional formatting when the UserDesignerOptions.DataBindingMode is set to DataBindingMode.Expressions or DataBindingMode.ExpressionsAdvanced.

See Conditionally Change a Control's Appearance to learn about the legacy approach to solving this task.

See Data Binding Modes to learn more about the available binding modes.

  • Switch to the Report Explorer and right-click the Styles category to create a new visual style.

    report-explorer-styles-new-style

  • Right-click the created styles and select Edit Styles.

    report-explorer-styles-edit

  • This invokes the Styles Editor for customizing the created style's appearance settings.

    styles-editor-appearance-settings

  • Create another style by cloning the existing one.

    styles-editor-clone

  • Customize the new style's appearance settings and close the editor.

    styles-editor-appearance-alternating

  • Back in the Report Explorer, select a report element to which you wish to assign the created styles.

    report-explorer-select-element

  • Switch to the Expressions section in the Properties window and click the ellipsis button for the control's StyleName property (you can find it under the BeforePrint event's category if you are using the ExpressionsAdvanced binding mode).

    expressions-style-name

  • This invokes the Expression Editor where you can specify the required condition for switching between the created styles.

    expressions-style-name-iif

Switch to Print Preview to view the resulting report:

conditional-styles