Jose,
>Did you understand ?
Hmmm...I see your point.
I have made a change to CGrid.SetOrder() listed below to accommodate your need. As you can see I have added a second parameter to the SetOrder method. You can pass the name of a tag in this parameter and SetOrder() will SET ORDER to it. I recommend that you still pass the ControlSource in the first parameter...we may do something with it in the future, and if we do, your code will be backward compatible (the challenges of framework programming <s>).
LPARAMETERS tcControlSource, tcTagName
LOCAL lnCount, lcField, lcIndexExpr
IF PCOUNT() > 1
SET ORDER TO TAG tcTagName
This.cTagName = tcTagName
ELSE
*----------------------------------
*-- Get the fieldname being used
*----------------------------------
lcField = ;
SUBSTR(tcControlSource, AT(".", tcControlSource) + 1)
*----------------------------------------------------------------
*-- See if the field name is in the leftmost part of the index
*-- expression OR simply within an UPPER() statement.
*-- If so, SET ORDER TO the index.
*----------------------------------------------------------------
FOR lnCount = 1 TO TAGCOUNT()
lcIndexExpr = UPPER(SYS(14, lnCount))
*--------------------------------------------------
*--- Allow for character indexes that are simply
*--- surrounded by "UPPER()". Remove "UPPER()".
*--------------------------------------------------
IF LEFT(lcIndexExpr,6) = 'UPPER('
lcIndexExpr = SUBSTR(lcIndexExpr,7)
lcIndexExpr = SUBSTR(lcIndexExpr,1,LEN(lcIndexExpr)-1)
ENDIF
IF lcIndexExpr = UPPER(lcField)
SET ORDER TO lnCount
*--- Save the tag name ---*
This.cTagName = TAG(lnCount)
EXIT
ENDIF
ENDFOR
ENDIF
IF TYPE("ThisForm") == "O"
Thisform.Refresh()
ENDIF
Regards,
Kevin McNeish
Eight-Time .NET MVP
VFP and iOS Author, Speaker & Trainer
Oak Leaf Enterprises, Inc.
Chief Architect, MM Framework
http://www.oakleafsd.com