Conditionally Change a Control's Appearance

<< Click to Display Table of Contents >>

Navigation:  User Interface Reference > Report Designer > Report Designer for WinForms > Create Reports > Styles and Conditional Formatting >

Conditionally Change a Control's Appearance

Interface Elements for Desktop > Report Designer > Report Designer for WinForms > Create Reports > Styles and Conditional Formatting in Reports > Conditionally Change a Control's Appearance

This tutorial describes the steps to conditionally change a control's appearance (e.g. make a Label's text red if its value exceeds some threshold). Thanks to the formatting rules feature, to achieve this, no scripts are required, so you shouldn't write any code.

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

1.Create a data-aware report.

2.Click the report's Smart Tag, and in the invoked actions list, click the ellipsis button for the Formatting Rule Sheet option.

img8560

And, in the invoked Formatting Rule Sheet Editor, create a new formatting rule (by using the img8593 button), and click the ellipsis button for its Condition property.

img11143

3.Then, in the invoked Condition 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.

img8562

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

4.Now, back in the Formatting Rule Sheet Editor, define the formatting to be applied (e.g. specify the desired font color).

img8563

To save the changes and quit the dialog, click Close.

5.Finally, select the band or control to which the formatting rule must be applied (in this example it is the Detail band), and via its Smart Tag, access its collection of Formatting Rules.

img8564

And, in the invoked Formatting Rules Editor, move the rule from left to right (using the > button), for it to come into effect for this band.

img11144

If multiple rules are applied, it is possible to customize their precedence, by using the up and down arrow buttons at the right of the dialog. 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.

The result is shown in the following image.

img11145

ExpandedCollapsed See Also

Conditionally Hide Bands

Conditionally Change a Label's Text

Copyright (c) 1998-2016 Developer Express Inc. All rights reserved.

Send Feedback on this topic to DevExpress.