Question

I'm using Power Builder 10.5 and I'm having a problem that seems simple at first, but can't get near the solution. Is it possible to color rows differently depending on a condition? I have a select statement that retrieves numerous rows, that have different status: status A means the row is active, ERR that something is wrong, F that is finished, and so on... What I need is the color of the column with status "ERR" to be red, and the color of the column with status "A" to be green. All else columns may be white.

I can do only half the job at the moment. I've added a dummy field in my Data Window, called "color". For all the cells I've written this in the design view, background color properties..

IF ( color =1, 65280, 16777215)

Now I move to the clicked event of my OK button where I retrieve data...

dw_1.Retrieve()
FOR ll_=1 to dw_1.RowCount()
ls_status=dw_1.GetItemString(ll_,"status")
IF ls_status='A' THEN
dw_1.SetItem(ll_, 'color', 1)
ELSEIF ls_status='ERR' THEN
??????
END IF
NEXT

The part with question marks is where I can't move forward. This highlights all my rows where status is "OK" green, but I can't seem to get the error ones red. I've tried manipulating the code in background color properties (trying to give him a condition if color=2), but I just keep getting the "Expression not valid" message. Modify method also didn't help me much, as I can't seem to make him color only does rows with "ERR" status using Modify method.

Any advice will help.

Was it helpful?

Solution

You should set your 'color' column in the SQL statement itself.

SQL something like

CASE status WHEN 'ERR' THEN 'R' WHEN 'A' THEN 'G' END

Then in an expression on the background color of the columns of your datawindow you can put something like

if (color[0] = 'R', RGB(255,0,0), if (color[0] = 'G', RGB(0,255,0), RGB(0,0,0))) 

OTHER TIPS

In the datawindow properties of the object or band, go to the background tab. The Color property has a little button with an equal sign (=) on it. Click that and write an expression to derive a RGB value based on the value of a column.

I wrote an article about this stuff here: PBDJ Article

You can use case statements in the computed property. Something like this:

case( status when 'ERR' then RGB(255,0,0) when 'A' then RGB(0,255,0) else RGB(0,0,0) )
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top