Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Rhinorhino on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How can I change ORDER() in a grid?

Tips -N- Tricks

How can I change ORDER() in a grid?

by  ChrisRChamberlain  Posted    (Edited  )
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]

WITH THISFORM.grid1
.SetAll([ForeColor],RGB(0,0,0),[Header])[color green] && Optional - highlights indexed column[color blue]
.Column1.Header1.ForeColor = RGB(0,0,255)[color green] && Optional - highlights indexed column[color blue]
.Refresh()
ENDWITH

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.
Register to rate this FAQ  : BAD 1 2 3 4 5 6 7 8 9 10 GOOD
Please Note: 1 is Bad, 10 is Good :-)

Part and Inventory Search

Back
Top