如何将VFP的grid设置成点击标题排序
1个回答
展开全部
首先在表单中新建一个方法,命名为:headerclick
写入如下代码:
=AEVENT(aSourceObj, 0)
oSourceObj = aSourceObj[1]
cRowName=osourceobj.CAPTION
cgrid='thisform.grid1' &&&&表格的名字
ogrid=&cgrid
cfilename=ogrid.RECORDSOURCE
IF EMPTY(cfilename) OR SELECT(cfilename)=0RETURNENDIFogrid.RECORDSOURCE=''
SELECT * FROM (cfilename) INTO CURSOR (cfilename+'_tmp')
USE IN (cfilename)
SELECT * FROM (cfilename+'_tmp') ORDER BY &crowname INTO DBF (cfilename)
USE IN (cfilename+'_tmp')
ogrid.RECORDSOURCE=cfilename
SELECT(cfilename)GOTO TOPogrid.SETFOCUS
然后在表格的refresh(刷新方法)里写入如下代码:
cgrid='thisform.'+ALLTRIM(this.name)
ogrid=&cgrid
FOR gnCount = 1 TO this.columncount && header代理
cheader='this.column'+alltrim(str(gncount))+'.header1'
oheader=&cheader
oheader.tooltiptext='单击按本列值重新排序表格数据'
BINDEVENT(oheader,"Click",thisform,"headerclick")NEXT当表格装载数据后,刷新表格(运行方法thisform.grid1.refresh),即可将表格中header的click事件设置为自定义方法的代理。当单击表格header时,即运行headerclick自定义方法,将表格数据源表重新排格
写入如下代码:
=AEVENT(aSourceObj, 0)
oSourceObj = aSourceObj[1]
cRowName=osourceobj.CAPTION
cgrid='thisform.grid1' &&&&表格的名字
ogrid=&cgrid
cfilename=ogrid.RECORDSOURCE
IF EMPTY(cfilename) OR SELECT(cfilename)=0RETURNENDIFogrid.RECORDSOURCE=''
SELECT * FROM (cfilename) INTO CURSOR (cfilename+'_tmp')
USE IN (cfilename)
SELECT * FROM (cfilename+'_tmp') ORDER BY &crowname INTO DBF (cfilename)
USE IN (cfilename+'_tmp')
ogrid.RECORDSOURCE=cfilename
SELECT(cfilename)GOTO TOPogrid.SETFOCUS
然后在表格的refresh(刷新方法)里写入如下代码:
cgrid='thisform.'+ALLTRIM(this.name)
ogrid=&cgrid
FOR gnCount = 1 TO this.columncount && header代理
cheader='this.column'+alltrim(str(gncount))+'.header1'
oheader=&cheader
oheader.tooltiptext='单击按本列值重新排序表格数据'
BINDEVENT(oheader,"Click",thisform,"headerclick")NEXT当表格装载数据后,刷新表格(运行方法thisform.grid1.refresh),即可将表格中header的click事件设置为自定义方法的代理。当单击表格header时,即运行headerclick自定义方法,将表格数据源表重新排格
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询