Add as many new form properties as you have indexed fields in your grid that intend to set to be ORDER(), ie [color blue].lGrid1Asc1[color black], [color blue].lGrid1Asc2[color black], [color blue].lGrid1Asc3[color black] etc.
In the [color blue]Grid1.Column1.Header1.Click()[color black] event put:-
[color blue]
lcAlias = ALIAS()[color green] && Save current Alias - optional[color blue]
SELE TABLENAME[color green] && .RecordSource of grid - optional[color blue]
IF THISFORM.lGrid1Asc1
SET ORDER TO TAG tagname ASCE
THISFORM.lGrid1Asc1 = .F.
ELSE
SET ORDER TO TAG tagname DESC
THISFORM.lGrid1Asc1 = .T.
ENDI
GO TOP[color green] && Optional[color blue]
SELE (lcAlias)[color green] && Restore current Alias - optional[color black]
Clicking on the header will select the index and toggle it from ascending to descending, Windows Explorer style. The header colour will also change to indicate which column currently is ORDER().
You can then modify and repeat the code in the other columns.
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.