The easiest way to do this is buy using an expression in the text color property of the column in the datawindow. In the expression you can check for whatever condition you need to change the color for an individual row.
For setting the background color of the entire detail-band (all columns) with a single expression, go to the Properties of the Detail band: right-click on the band -> Properties -> Properties -> Color and place an expression such as:
However, the above is for display-only purposes and will not print as you see it.
For the text color of the columns, you could set the Color property of each column similar to the above by going to the Properties of the column. If you want to print alternating colors for each row, you will have to use a rectangle control, send it to back, set the background color of all the columns to Transparent, make the rectangle Visible: Properties -> Expressions -> Visible:
But what if I want to do it in coding? Let say, I have a store procedure to save all the rows from the datawindow into the database. Meanwhile, it will do some validation to check each record whether is qualify to save into the database. If does not pass the validation it will return false and that particular row of record will be highlighted( or change to other color).
Is it possible to do this?
You will have to use Computed-Columns in your SQL to achieve this. Include a computed-column in your dw's SQL:
'N' AS Flag
Remove this column from the dw's layout so the user does not see it. Also, exclude this from the updateable columns. Then, for each column, set its Color Expression to:
If( Flag = 'Y', 255, 0 )
When validation fails for any row, simply SetItem( Flag, "Y" ) for the row and the row is displayed in a different color.
Beware that setting a value to a column changes the row's status to DataModified!/NewModified!. If your validation logic validates unmodified rows and you set the Flag to display the row in a different color, the row's status changes to DataModified! although nothing was changed after its retrieval.
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.