* Grid.init this.SetAll("DynamicBackColor", ; "IIF(RecNo(This.RecordSource) = this.nCurRec, "+; "RGB(0,0,255),RGB(255,255,0))", "Column") * Grid.AfterRowColChange this.nCurrec = recno(this.recordsource) * That's all :) It Doesn't need a refresh when you're in grid * For moving outside of grid (ie: a commandbutton skips in grid.recordsource thisform.myGrid .nCurrec = recno(.RecordSource) .Refresh endwith * Another sample * Changing colors for newly appended records in buffered mode * Appended records have negative recno till updated ;) * Grid.Init WITH this IF !empty(.RecordSource) .SetAll("DynamicBackColor", ; "IIF(RecNo(This.RecordSource) < 0,RGB(0,0,255),RGB(255,255,0))", "Column") .SetAll("DynamicForeColor", ; "IIF(RecNo(This.RecordSource) < 0,RGB(255,255,255),RGB(0,0,0))", "Column") ENDIF ENDWITHIn fact this doesn't need to be in grid.init. It could be in any method, event. Even you could use this in a timer event to make a flashing effect. Since grid does the evaluation for visible part (Cool:) calling this in a timer event doesn't cause a noticable performance degrade.
>ThisForm.nRecNo = RECNO() >ThisForm.Grid1.SetAll("DynamicBackColor", ; > "IIF(RECNO()=This.nRecNo), RGB(255,255,147), RGB(240,240,240))", "Column") >>
>STORE RECNO() TO mSelectedRecord >ThisForm.Grid1.SetAll("DynamicBackColor", ; > "IIF(RECNO()=mSelectedRecord), RGB(255,255,147), RGB(240,240,240))", "Column") >>
>ThisForm.Grid1.SetAll("DynamicBackColor", ; > "IIF(MOD(RECNO( ), 2)=0, RGB(255,255,255) ; > , RGB(0,255,0))", "Column") && Alternate white and green records >>
>>>STORE RECNO() TO mSelectedRecord >>> >>>* Debugging information... >>>MESSAGEBOX("What is mSelectedRecord? mSelectedRecord is:" + STR(mSelectedRecord)) >>>IIF(RECNO()=mSelectedRecord, MESSAGEBOX("RECNO() is equal to mSelectedRecord"), MESSAGEBOX("It doesn't")) >>>* End of Debugging information >>> >>>ThisForm.Grid1.SetAll("DynamicBackColor", ; >>> "IIF(RECNO()=mSelectedRecord), RGB(255,255,255), RGB(0,255,0))", ; >>> "Column") >>>>>>