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!

How do I set the color of a row based on a column value?

Status
Not open for further replies.

kaul125

Programmer
Jan 29, 2002
87
US
I have a ddlb/dddw column in my datawindow. When the user selects a certain value in this column I want to change the color of the entire row to a certain color.

How do I change the color of the row(not the column)?

Thanks

kaul125
 
In datawindow design, select the details band and open the properties page. There you will find a list box for selecting color of the row where you can define the conditional expression. You only need to know the color code which you wish to set for the row

e.g. if you want your default row colour to be mint and the selected row color to be blue you can set the expression as

if(<expression for column check say col1 = something>,<integer color code for blue>,<integer color code for mint>)

If you have any doubt about the integer value of the colour, you create a dummy datawindow and export it to srd and open in a text editor.There you will be able to figure out the colour codes.

RT
 
rt63,

Thanks, this partially worked. When you initially open the window and the column that the detail band expression is based on has the value I want, the rows are the appropriate color. However, when I select a different value for that column in the ddlb, I expect the whole row to change to the color I set for the false condition in the expression on the detail band. Instead, only the column that I changed the value for turns to the appropriate color and the other columns stay the same until I tab to it then it changes color. For example:

//detail band expression
If(col1=1,rgb(255,0,0),rgb(0,255,0)) //True=red, False=green

If I change the value to 1 in col1, then col1 turns to red and the other columns stay green until I tab to them and then it turns to red.

I want the whole row to change colors as soon as I change the value in col1. How do I accomplish this?

I'm assuming I would have to have the detail band expression in the itemchanged event.If so, what is the correct syntax in the event to access the detail band of the dw? I'm using PB6.5

kaul
 
Try the following

Create some window function say wf_setcolor


dw_1.Modify('DataWindow.Detail.Color=&quot;'+string(rgb(0,255,0))+'~tif(col1 = 1, rgb(255,0,0) , rgb(0,255,0))&quot;')
return


and in itemchanged event of the datawindow post this function as

post function wf_setcolor()


This will probably solve your problem.

RT
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top