Hans,
The code I wrote sets the background color of all columns (hence row).
DynamicBackColor AFAIK exists in all versions of VFP. This is from VFP5 help as is (in index write DynamicBackColor) :
"Specifies the background and foreground colors of a Column object. The colors are re-evaluated at run time each time the Grid control is refreshed. Available at design time; read-write at run time.
Syntax
Column.DynamicBackColor[ = cExpression]
Column.DynamicForeColor[ = cExpression]
Settings
cExpression Specifies an expression in quotation marks that is re-evaluated at run time whenever the Grid control is refreshed. The run-time evaluation must result in a single color value.
Remarks
You can use the DynamicBackColor and DynamicForeColor properties to create special effects, such as displaying the odd-numbered rows in green and the even-numbered rows in gray."
Try this code :
oForm = createobject('myForm')
oForm.show
read events
define class myForm as form
add object myGrid as grid with name='MyGrid'
procedure load
create cursor Test (balance i, myDate d)
for ix = 1 to 1000
insert into Test values (int(rand()*10000), date()-int(rand()*100))
endfor
locate
endproc
procedure init
this.myGrid.setall('DynamicBackColor', ;
'iif(Test.Balance < 2000, rgb(0,255,255),rgb(255,255,255))')
endproc
procedure queryunload
clear events
endproc
enddefine
You might also want to look FoxyClasses sample download (follow link in signature). Most of the classes are compatible with VFP5.
Cetin
>Hello Cetin,
>
>if I understand correctly, the code you are proposing is to change the color of a column. What I want to do is to change the color of some rows that meet a certain condition.
>
>I tried your code (thisform.myGrid.SetAll('DynamicBackColor', 'iif(myAlias.Balance < 100, rgb(0,255,255),rgb(255,255,255))') ) but it did not work. I can't find the property "DynamicBackColor" in the help neither. Maybe this property does not exist in VFP 5.0 ??
>
>Greetings,
>
>Hans