在表单上建立一GRID,RECORDSourcetype=0,recordsource=表名,在GRID各列的HEADER1的CLICK事件中写入THISFORM.sortt;
(THIS.PARENT.CONTROLSOURCE,RIGHT(ALLT(THIS.CAPTION),2),VAL(SUBSTRTHIS.PARENT.NAME,7,2)),;
this.Parent.Parent.Name,this.Parent.Parent.RecordSource) &&**..字段名,升降序,第几列,表名,表名
在FORM中新建一方法SORTT,代码如下:
LPARAMETERS xfield,xsort,xcol,xgrid,xtable &&**..字段名,升降序,第几列,表格名,表名
IF PARAMETERS()<4
RETURN .F.
ENDIF
SET INDEX TO
LOCAL TEM1
IF xsort='△'
SELECT * FROM &xtable ORDER BY &xfield DESC INTO CURSOR TEM1
ELSE
SELECT * FROM &xtable ORDER BY &xfield ASC INTO CURSOR TEM1
ENDIF
IF _tally>0
SELECT (xtable)
ZAP
APPEND FROM DBF('TEM1')
ELSE
RETURN
ENDIF
vst='thisform.'+xgrid
IF !EMPTY(vst)
FOR i=1 TO &vst..COLUMNCOUNT &&**..先去掉▽(△)再加△(▽)
st0=vst+'.COLUMN'+ALLT(STR(i))+'.HEADER1.CAPTION'
IF AT(RIGHT(ALLT(&st0),2),"▽△")!=0
&st0.=LEFT(ALLT(&st0),LEN(ALLT(&st0))-2)
ENDIF
IF i=xcol &&**..第几例
IF AT(xsort,"▽△")=0.OR.xsort="▽"
&st0.=&st0+"△"
ELSE
&st0.=&st0+"▽"
ENDIF
ENDIF
ENDFOR
ENDIF
SELECT (xtable)
THISFORM.refresh
SELECT (xtable)
GO TOP
THISFORM.refresh
[[it] 本帖最后由 ibmlang_002 于 2008-9-13 14:19 编辑 [/it]]