Thanks, Mike and Olaf. I've followed your advises and here it's my code in the Init of the Grid.
*--- curColor
Create Cursor curColor(iColor I)
*--- Set the relationship
Select (This.RecordSource)
Go Top
Set Relation To Recno() Into curColor
*--- Populate curColor
Select (This.RecordSource)
Go Top
Local lnRow, lnColor
lnRow = 0
lnColor = 0
Scan
lnRow = lnRow + 1
lnColor = Iif( Mod(lnRow, 2)==0, RGB(128,255,255), RGB(255,255,255) )
Insert Into curColor values (lnColor)
EndScan
*--- Alternate white and blue records
Select (This.RecordSource)
Go Top
This.SetAll('DynamicBackColor', 'curColor.iColor', 'Column')
So far, when I first display the Grid, all is good. When I try using different columns for sorting, I use the next code in a custom method:
*--- Zap curColor
Set Safety Off
Zap in curColor
Set Safety On
*--- Order for the table
Select (This.Grid1.RecordSource)
Set Order To (sortField) &sortOrder In (This.Grid1.RecordSource)
Go Top In (This.Grid1.RecordSource)
*--- Populate curColor (again), so the SET RELATION TO applies to the newly main sorted table.
Select (This.Grid1.RecordSource)
Go Top
Local lnRow, lnColor
lnRow = 0
lnColor = 0
Scan
lnRow = lnRow + 1
lnColor = Iif( Mod(lnRow, 2)==0, RGB(128,255,255), RGB(255,255,255) )
Insert Into curColor values (lnColor)
EndScan
This.Grid1.SetFocus()
***This.Grid1.SetAll('DynamicBackColor', 'curColor.iColor', 'Column')
This.Grid1.Refresh
Sorting works, but the colours are assigned the same like in the Init method (the records have the same colouring, this time not alternately, obviously). I tried issuing again the SetAll() (commented here), but no effect. Any hints?
Thanks.
Neculai