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

Problem combining conditional formatting with column shading

Status
Not open for further replies.

montypython1

Technical User
Jan 12, 2005
187
US
Greetings,

I have a grid that worked perfectly until I applied a conditional format to the rows of the grid.

Originally, the grid simply shaded in GREEN and BLUE the 'backcolor' of specific vertical columns. No problem. Then I applied a conditional format to the rows of the grid, using the INIT of the form, and the following code:
thisform.st_Grid01.SetAll("dynamicbackcolor", ;
"IIF( TaxDiff1 = 0 , RGB(255,255,255) , RGB(255,220,220))" , "Column" )
Notice that the previous code requires an RGB setting whether the criteria is True or False. This caused every row's background to be either RED or WHITE (replacing the previous shading of those specific vertical columns). I just want to highlight in red any row that was out-of-balance ( where 'TaxDiff1' <> 0 ).

Is there a way to apply the conditional format to specific rows if the criteria is met, while leaving the original backcolor if the criteria is NOT met?

Any ideas would be greatly appreciated.

Thanks,
Dave Higgins
 
Well, RGB(255,255,255) is white. The solution is to use the color stored in column.backcolor. You can't use Setall with this.

You may simply try "...this.backcolor..." instead of "...RGB(255,255,255)...", but the code in dynamicbackcolor is not run in the context of a column, so THIS.something would surely give an invalid expression.

make it a loop:
Code:
local lcRed, ii
lcRed = Transform(RGB(255,220,220))
with thisform.st_grid01
   for ii = 1 to .columncount
     .columns(ii).dynamicbackcolor=;
     "IIF(TaxDiff1=0,"+transform(.columns(ii).backcolor)+","+lcRed+")"
   endfor ii
endwith

And if you change the backcolor of a column at runtime, you also need to change the dynamicbackcolor expression.

Bye, Olaf.
 

Hi Dave,

I'd be inclined to create a custom property (of the grid) to hold the "default" backcolor, that is, the backcolor to apply when the criterion is not met.

Apart from that point, I'd go with Olaf's solution.

Mike

__________________________________
Mike Lewis (Edinburgh, Scotland)

My Visual FoxPro site: www.ml-consult.co.uk
 
Hi Olaf and Mike,

Thank you both. I will implement your suggestions immediately.

Thanks again.

Dave Higgins
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top