Question

I can change the Text color at design time by accessing to TextBox properties, however I would like to change the Text color at run time depending on some condition (relating to the cell value). For example, if the cell value is greater than 0, the text color is green, otherwise it should be red.

Could I achieve such a thing in Local Report?

Was it helpful?

Solution

Currently, I know only a way to refer to a specified cell's value is using the exact expression which the cell has, and with that I have the following solution for you:

It's so simple, just right click your textbox, select TextBox properties, then select Font tab, you can see there is a Color selector, you can select a color you want right at design time, if not, you can specify the expression for its color by clicking on the fx button on the right side of the color combobox. Then type the following expression, I suppose you want to make it Green when its value is greater 0, otherwise its value is Red:

=IIF([The exact current TextBox's expression] > 0, "Green", "Red")

By default, the color expression is only Black (without the equal sign), but to use more complex expression, you have to add the equal sign first, otherwise there will be an error saying that the specified color is not a valid color, plus the color is specified by a string representing color name. To specify more various color in an expression, you can use the hex string format for color (as used in web), e.g #ff0000 can work the same as Red.

Hope it helps!

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top