INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Jobs

Tips -N- Tricks

How can I change ORDER() in a grid? by ChrisRChamberlain
Posted: 1 Feb 01

Add as many new form properties as you have indexed fields in your grid that intend to set to be ORDER(), ie .lGrid1Asc1, .lGrid1Asc2, .lGrid1Asc3 etc.

In the Grid1.Column1.Header1.Click() event put:-

lcAlias = ALIAS() && Save current Alias - optional
SELE TABLENAME && .RecordSource of grid - optional

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 && Optional

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

SELE (lcAlias) && Restore current Alias - optional

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.

Back to Microsoft: Visual FoxPro FAQ Index
Back to Microsoft: Visual FoxPro Forum

My Archive

Resources

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close