>I'm still trying to figure out a way to make each cell on a grid row possibly have a different color.
>i.e. field one of the grid on the first row(record) will be blue, the second field on the first row(record) will be green.
>BUT
> field one of the grid on the second row(record) will be green, the second field on the second row(record) will be blue.
>
>these colors would be determine by the value of the field ie field1 = 'C' color = blue but if field1 = 'B' color = green
>
>Is there anyway to accomplish this?
>
>Thanks in advance,
>
>Brad
I think the following code can get you started, careful thou, I just wrote it without error handling or any other safeguard, the only purpose is to show you one way I think you can solve the problem:
Basically you set the DynamicBackColor of each column to one or many methods (in my case I used one method and a parameter that represents the colum) The color for column 1 is red-ish if there is an 'A' or a '8' in field 1, otherwise white, and for column 2 green-ish if there is a 'B' or an '9' in field 2, not very exciting stuff but hopefully it can get you some traction
local loForm
loForm = CreateObject('myForm')
loForm.Show(1)
define class myForm as Form
width = 300
height = 600
add object grdData as Grid with width = 280, height = 560, left = 5, top = 5
add object btnExit as commandbutton with top = 566, height = 30, left = 5, Caption = 'Exit'
procedure btnExit.Click()
thisform.Release()
endproc
function Load()
local i
create cursor c_test (PK I autoinc, Col1 C(10), col2 C(10))
for i = 1 to 100
insert into c_test (Col1, Col2) values (Sys(2015), Sys(2015))
endfor
go top
return .t.
endfunc
function Init()
thisform.grdData.Column2.DynamicBackColor = 'thisform.getColor(1)'
thisform.grdData.Column3.DynamicBackColor = 'thisform.getColor(2)'
thisform.grdData.AutoFit()
return .t.
endfunc
function getColor(tnColumn as Byte) as Integer
local lnColor
do case
case tnColumn = 1
lnColor = Iif('A'$c_test.Col1 or '8'$c_test.Col1, Rgb(192, 0, 0), Rgb(255, 255, 255))
case tnColumn = 2
lnColor = Iif('B'$c_test.Col2 or '9'$c_test.Col2, Rgb(0, 192, 0), Rgb(255, 255, 255))
otherwise
lnColor = Rgb(0, 0, 192)
endcase
return lnColor
endfunc
enddefine
"The five senses obstruct or deform the apprehension of reality."
Jorge L. Borges?
"Premature optimization is the root of all evil in programming."
Donald Knuth, repeating C. A. R. Hoare
"To die for a religion is easier than to live it absolutely"
Jorge L. Borges