>>>If you use the database in the correct order, you can use the recno() odd/even to turn color 1 - color 2. BUT WHAT CAN YOU DO IF YOU HAVE ANOTHER ORDER (THE RECNO() IS NOT IN ORDER ANYMORE)
>>
>>Here's a solution from Cetin,
>>
>>This works faster with tables whose reccount() <= 65000 (for larger tables a cursor could be used instead):
>>
>>
>>
>>select recno() ;
>> from (this.recordsource) ;
>> order by myOrder ;
>> into array ;
>> thisform.aOrder
>>this.setall("DynamicBackColor",;
>> "iif(ascan(thisform.aOrder,"+;
>> "recno())%2=0,rgb(0,255,0),rgb(255,255,0))","Column")
>
>Just to add - another way to speed things up is to simplify any dynamic expression you may be using. They are evaluated for each cell on each refresh of the grid, so I sometimes go as far as to replace the rgb() with its result:
>
>this.setall("DynamicBackColor",;
> "iif(ascan(thisform.aOrder,"+;
> "recno())%2=0,"+tran(rgb(0,255,0))+;
> ","+tran(rgb(255,255,0))+")","Column")
>This way there's two function calls (even if it's such a simple function as rgb() in the expression.
>In the framework we use there was a method call in the dynamicbackcolor expression; the method was just a five-liner, if [expression] - return this.backcolor - else - return thisform.backcolor - endif. Just replacing the method call with an iif() expression containing constants sped it up incredibly. The difference was really visible in the debugger, it was like "oh no it's refreshing again, lemme get some coffee until it finishes" compared to "ok, one, two, here it is".
Good Dragan,
Then you could also make it shorter and increase support count to 65000*2 recs for an array.
-First select into a cursor
-Select only odds or evens into array
-Change expression to something like :
'(ascan(recno())*'+tran(myColor1-myColor2)+tran(myColor1)+')'
No iif() too :)
Say I put only odd ones in array and oddcolor=120000, evencolor=100000
(ascan(recno())*20000+(100000)
Cetin