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 SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Grid Row Colours

Status
Not open for further replies.

AlastairOz

Technical User
Jul 27, 2010
81
0
0
AU
I am trying to get a grid to have different row colours according to the current status of that row. For instance:
If column called "Progress" has "OVERDUE!" in the row then the row should be say coloured red.
If another row has the "Progress" as being "Near Due" then
the colour of that row should be say green.

When I use the DynamicBackColor property, eg:

thisform.grdjobs.setall("DynamicBackColor","iif( Progress = ALLTRIM(UPPER('OVERDUE!!')), rgb(255,70,70), rgb(255,255,255) )","Column")
thisform.grdjobs.setall("DynamicBackColor","iif( Progress = ALLTRIM('Assign NOW!'), rgb(0,255,0), rgb(255,255,255) )","Column")

The second function is evaluated, in this case only
the rows where "Progress" is 'Assign NOW!' are
coloured green. The first function is not evaluated, or the second function is over writing the first.

How do I get different colours for different rows?
(Different colours in the same grid at the same time)
 
UPPER('OVERDUE!!') is 'OVERDUE!!', there is no need for the UPPER there. If the Progress field can be "overdue!!" or "Overdue!!" then you need the Upper there:

thisform.grdjobs.setall("DynamicBackColor","iif( Upper(Progress) = 'OVERDUE!!', rgb(255,70,70), rgb(255,255,255) )","Column")

And yes, the second setall overwrites the first, this is not a stack of values, there is only one expression, the last assigned in DynamicBackcolor.

What you'd need is an ICASE()
thisform.grdjobs.setall("DynamicBackColor","icase( Upper(Progress) = 'OVERDUE!!', rgb(255,70,70), Upper(Progress) = 'ASSIGN NOW!', rgb(0,255,0), rgb(255,255,255) )","Column")

Bye, Olaf.
 
Icase is new in VFP9, if using older VFP you need to use nested iifs:

icase(condition1, value1, condition2, value2, otherwisevalue) translates to
iif(condition1,value1,iif(condition2, value2, otherwisevalue))

Bye, Olaf.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top