Skip to main content Skip to footer

How To Conditionally Change the Formatting in a Text Box Control

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:

  1. Drag a Textbox Control onto the report designer.
  2. Navigate to the properties pane on the right side of the designer or Right Click the textbox and select Properties.
  3. Find which property you would like to change. EX: BackgroundColor
  4. Click the property and use the drop down arrow on the right hand side to select <Expression...> 
  5. 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.
  6. 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.
  7. 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

Christian Pacelli

Technical Engagement Engineer