Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

text color 1

Status
Not open for further replies.

beti

Programmer
Oct 6, 2002
26
US
Hi,

I'm using PowerBuilder 7.0. Does anyone know how to set the text color of a specific row in a datawindow?

Thanks
 
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.
 
Beti,

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:

If( Mod( GetRow(), 2 ) = 0, RGB( 255,255,255 ), RGB( 192,192,192 ))

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:

If( Mod( GetRow(), 2 ) = 0, 0, 1 )

---
PowerObject!
-----------------------------------------
PowerBuilder / PFC Developers' Group
 
Hi!

Thanks for your reply!

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?

Thanks
 
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.

---
PowerObject!
-----------------------------------------
PowerBuilder / PFC Developers' Group
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top