Background:
When generating a report in ActiveReports.NET you may want to conditionally change the formatting on the control based on the values that are coming from your data. Formatting can include background color, font color, font size, text alignment, and so much more.
Steps To Complete:
- Drag a Textbox Control onto the report designer.
- Navigate to the properties pane on the right side of the designer or Right Click the textbox and select Properties.
- Find which property you would like to change. EX: BackgroundColor
- Click the property and use the drop down arrow on the right hand side to select <Expression...>
- In the Expression Editor navigate through the tree using Common Values > Program Flow. Here you will have a number of options to change the format based upon various conditions. EX: A switch case where you will have a number of different options to choose from, or an IIF statement that will allow you to use a simple If Else statement.
- Then choose the field that you would like to use to change the formatting. EX: IIF(Fields!SalesAmount > 50,000.00, "Green", "Red") This statement will look at the Sales Amount field. If it is greater than 50,000.00 the background color will be set to Green, otherwise it will be set to Red.
- Once your expression is complete you can click OK and preview your report.
Resources:
If you would like to learn more about the properties of the Textbox Control you may do so here
/activereportsnet/docs/latest/online/textbox.html
If you would like to learn more about expressions you may do so here:
/activereportsnet/docs/latest/online/expressions.html
Tags:
Christian Pacelli
Technical Engagement Engineer