Conditionally Change a Label's Text

<< 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 Label's Text

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

This tutorial demonstrates how to change a label's text if a certain condition is met, without using scripts.

To conditionally change a label's text, do the following.

1.Create a new report and bind it to a data source.

2.To create a calculated field, in the Field List, right-click any item inside the created data source, and on the invoked menu, choose Add Calculated Field.

img8465

3.Select the calculated field, and in the Property Grid, set its Field Type to String. Then, click the ellipsis button for its Expression property.

And, in the invoked Expression Editor, define the required logical condition for the calculated field (e.g. Iif([UnitsOnOrder] == 0, 'None', [UnitsOnOrder]), which means that if the UnitsOnOrder data field's value is equal to 0, the control's text will be replaced with None).

img8880

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

4.Finally, drop the required data fields (and the created calculated field as well) from the Field List onto the report's Detail band.

img8881

The report is now ready. Switch to the Preview Tab, and view the result.

img8882

ExpandedCollapsed See Also

Conditionally Change a Control's Appearance

Conditionally Hide Bands

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

Send Feedback on this topic to DevExpress.