主题:[讨论]请高手帮忙看以下代码
各位大大,以下代码是为了实现点击表头排序,但是一直提示出错,以下红字表示:
请帮忙看看要如何修改,谢谢。
DEFINE CLASS NewHeader as Header
Name="NewHeader"
PROCEDURE click
oGrd=This.Parent.Parent
nColumns=This.Parent.ColumnOrder
Thisform.LockScreen= .T. &&锁定屏
cFileName=oGrd.RecordSource &&取得绑定的数据源名
IF !EMPTY(cFileName)
IF RECCOUNT('&cFileName')>0
FOR i=1 TO This.Parent.Parent.ColumnCount
cField=This.Parent.ControlSource &&取得绑定的字段名
SELECT (cFileName)
IF INLIST(VARTYPE(&cField),"C","N","D","T","Y","L") &&判断字段数据类型
IF i=nColumns && 点击的GRID头
cCap=ALLTRIM(This.Caption)
DO CASE
CASE AT('▽',cCap)>0
This.Caption=STRTRAN(cCap,'▽','△')
SELECT &cFileName
INDEX on &cField TO gIdx
SET ORDER TO gIdx ASCEN*
CASE AT('△',cCap)>0
This.Caption=STRTRAN(cCap,'△','▽')
SELECT &cFileName
INDEX on &cField TO gIdx
SET ORDER TO gIdx DESCEN*
OTHERWISE
This.Caption=This.Caption+SPACE(1)+'▽'
SELECT &cFileName
INDEX on &cField TO gIdx
[color=FF0000]SET ORDER TO gIdx DESCEN* [/color]
ENDCASE
ELSE && 没有点击的GRID头
cCap=ALLTRIM(oGrd.Columns(i).Header1.Caption)
DO CASE
CASE AT('▽',cCap)>0
oGrd.Columns(i).Header1.Caption=STRTRAN(cCap,'▽','')
CASE AT('△',cCap)>0
oGrd.Columns(i).Header1.Caption=STRTRAN(cCap,'△','')
OTHERWISE
***不变
ENDCASE
ENDIF &&&& 结束点击的GRID头判断
ENDIF &&结束字段数据类型判断
ENDFOR &&结束
ENDIF
ENDIF
SELECT (cFileName)
GO TOP
Thisform.LockScreen= .F. &&解锁屏
oGrd.Refresh
ENDPROC
ENDDEFINE
[em1]
请帮忙看看要如何修改,谢谢。
DEFINE CLASS NewHeader as Header
Name="NewHeader"
PROCEDURE click
oGrd=This.Parent.Parent
nColumns=This.Parent.ColumnOrder
Thisform.LockScreen= .T. &&锁定屏
cFileName=oGrd.RecordSource &&取得绑定的数据源名
IF !EMPTY(cFileName)
IF RECCOUNT('&cFileName')>0
FOR i=1 TO This.Parent.Parent.ColumnCount
cField=This.Parent.ControlSource &&取得绑定的字段名
SELECT (cFileName)
IF INLIST(VARTYPE(&cField),"C","N","D","T","Y","L") &&判断字段数据类型
IF i=nColumns && 点击的GRID头
cCap=ALLTRIM(This.Caption)
DO CASE
CASE AT('▽',cCap)>0
This.Caption=STRTRAN(cCap,'▽','△')
SELECT &cFileName
INDEX on &cField TO gIdx
SET ORDER TO gIdx ASCEN*
CASE AT('△',cCap)>0
This.Caption=STRTRAN(cCap,'△','▽')
SELECT &cFileName
INDEX on &cField TO gIdx
SET ORDER TO gIdx DESCEN*
OTHERWISE
This.Caption=This.Caption+SPACE(1)+'▽'
SELECT &cFileName
INDEX on &cField TO gIdx
[color=FF0000]SET ORDER TO gIdx DESCEN* [/color]
ENDCASE
ELSE && 没有点击的GRID头
cCap=ALLTRIM(oGrd.Columns(i).Header1.Caption)
DO CASE
CASE AT('▽',cCap)>0
oGrd.Columns(i).Header1.Caption=STRTRAN(cCap,'▽','')
CASE AT('△',cCap)>0
oGrd.Columns(i).Header1.Caption=STRTRAN(cCap,'△','')
OTHERWISE
***不变
ENDCASE
ENDIF &&&& 结束点击的GRID头判断
ENDIF &&结束字段数据类型判断
ENDFOR &&结束
ENDIF
ENDIF
SELECT (cFileName)
GO TOP
Thisform.LockScreen= .F. &&解锁屏
oGrd.Refresh
ENDPROC
ENDDEFINE
[em1]