Or, the same example using an array:
<code>
Local testform
testform = CreateObject("colorform")
testform.show(1)
Define Class colorgrid as Grid
DIMENSION aColors[3,2]
aColors[1,1] = Rgb(255,0,0)
aColors[2,1] = Rgb(0,0,255)
aColors[3,1] = Rgb(0,255,0)
aColors[1,2] = Rgb(0,0,255)
aColors[2,2] = Rgb(255,0,0)
aColors[3,2] = Rgb(255,255,0)
columncount = 2
height = 200
left = 24
top = 18
width = 320
column1.dynamicbackcolor = "this.aColors[RECNO('testing'),1]"
column2.dynamicbackcolor = "this.aColors[RECNO('testing'),2]"
*- Note the column# here!
EndDefine
Define Class colorform as Form
datasession = 2
Add Object grid1 as colorgrid
Procedure load
Create Cursor testing (col1 c(15), col2 c(15))
Insert into testing values ("red", "blue")
Insert into testing values ("blue", "red")
Insert into testing values ("green", "yellow")
LOCATE
EndProc
EndDefine
</code>
-----Oorspronkelijk bericht-----
Van: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]
Namens Whil Hentzen (Pro*)
Verzonden: vrijdag 27 juli 2007 0:15
Aan: [EMAIL PROTECTED]
Onderwerp: VFP-9 Grid column colors, revisited
In a message long, long ago (Feb 07), Sytze asked about changing
different grid columns as well as rows with DynamicBackColor:
> I have a grid with an INIT like:
> thisform.Grid1.SetAll("DynamicBackColor","IIF(calltype="IN",
> RGB(192,192,192),RGB(255,255,255))", "Column")
>
> This give me an easy way to differentiate an IN call from an OUT call,
> on different ROWS.
>
> It looks like this prevents me from having a specific COLUMN in a
> different color from the rest. Is this true ?
Sietse Wijnker then responded:
> The 3rd param in the SetAll method is to specify the class where the
> property is set. In this case specifying the column-class isn't needed
> because the DynamicBackColor property only applies to the columns.
> The SetAll sets all columns DynamicBackColor property to the specified
> value. If you want a specific column display in another color, you'll have
> to reset the DynamicBackcolor property or at least alter it.
> B.T.W. The expression in all the dynamic properties are evaluated in the
> scope of the grid, not the column, so using 'this.' in the expression
refers
> to the grid!
I'm trying to take this one step further. I would like to change the
backcolor of any cell in a grid. I've got a cursor supporting the grid,
with columns named c1, c2, etc., and an array of colors that map to the
cursor, like so:
col1 col2
row1 green red
row2 red yellow
row3 blue yellow
and want to use that as the dynamic back color for each cell in the grid.
And I'm close, oh so close....
Option 1:
thisform.grid.setall("DynamicBackColor", ;
"eval(thisform.aCellColor[recn('csrGrid'), ;
<some expression>],) ;
")
but no matter how much fidgeting I do, I can't get anything to work for
'some expression' that will return the column number in the same manner
as recn() works for the row number.
Option 2:
I've also tried spinning through each column, setting dynamicbackcolor
for just that column, but that has no effect:
thisform.grid.column1.dynamicbackcolor ;
= thisform.aCellColor[recn('csrGrid'),1]
but this puts the same color in every row - so column 1 is green for
rows 1->3.
Ideas?
Whil
[excessive quoting removed by server]
_______________________________________________
Post Messages to: [email protected]
Subscription Maintenance: http://leafe.com/mailman/listinfo/profox
OT-free version of this list: http://leafe.com/mailman/listinfo/profoxtech
Searchable Archive: http://leafe.com/archives/search/profox
This message: http://leafe.com/archives/byMID/profox/[EMAIL
PROTECTED]@sw-software.nl
** All postings, unless explicitly stated otherwise, are the opinions of the
author, and do not constitute legal or medical advice. This statement is added
to the messages for those lawyers who are too stupid to see the obvious.