locked
How to change the color of text in a texbox using expression in ssrs RRS feed

  • Question

  • HI i need some help with text color in texbox using an expression,i have a report with some table and had a text with with positive numbers and negative number my requirement here is i need to write an expression like


    iif(Fields!Price.Value>0)
    then the textcolor should be Black if its less than 0 then the text should be in Red color can any one give me suggestion on how to do that
    Tuesday, March 22, 2011 2:39 PM

Answers

  • Hi raju9789,

    1. Select your text-box

    2. Hit F4 to open text-box properties

    3. Under Font, select Color (hit drop down menu button)

    4 Select Underneath Expression

    5 Write expression as:-

    = IIf ( Fields!Price.Value>0, "Black", "Red" )

    Please let us know your feedback.

    Thanks

    Kumar


    KG, MCTS
    • Marked as answer by raju9789 Tuesday, March 22, 2011 3:54 PM
    Tuesday, March 22, 2011 2:46 PM

All replies

  • Hi raju9789,

    1. Select your text-box

    2. Hit F4 to open text-box properties

    3. Under Font, select Color (hit drop down menu button)

    4 Select Underneath Expression

    5 Write expression as:-

    = IIf ( Fields!Price.Value>0, "Black", "Red" )

    Please let us know your feedback.

    Thanks

    Kumar


    KG, MCTS
    • Marked as answer by raju9789 Tuesday, March 22, 2011 3:54 PM
    Tuesday, March 22, 2011 2:46 PM
  • It worked fine.

    Thanks for the solution.

    Have you answered any more questions? then please feel free to let me know.

    Monday, July 15, 2013 9:32 PM
  • I think this works only from 2010 releases. I'm using 2008 R2, it doesn't work. 


    rajdeep

    Wednesday, March 30, 2016 11:11 PM
  • Hi Rajdeep,

    It should also work with 2008R2.

    1. My sample:

    2. Select the proper Textbox and open the Color property:

    3. Here is the expression to use:

    =IIF(Fields!Amount.Value < 0, "red", "black")

    4. Results:

    Hope that helped!


    Pierre Petesch

    If my post helped you to solve your issue, please mark it as answered.

    If you can't explain it simply, you don't understand it well enough.

    LinkedIn:   


    Thursday, March 31, 2016 7:58 AM
  • The best way, as you can apply it to any / all textboxes at the same time is using the self referencing property "Me.":

    =IIF(Me.Value < 0, "Red", "Black")

    Friday, June 9, 2017 9:27 AM
  • it work for me, thanks !

    Friday, July 13, 2018 8:21 PM