您的位置:首页 > 其它

关于在VFP中用表格控件浏览数据表时的分页浏览

2007-04-02 18:57 411 查看
有一数据表ax.dbf,字段若干

有一表单,设置表格控件1个(grid1),按钮控件5个(功能分别为打开表、分页、上一页、下一页、关闭表)

假设所有文件都放在桌面上

要实现的功能是分页浏览

表单init代码

public rno,rc,pno,pc
SET SAFETY OFF
set path to C:/Documents and Settings/jwc/桌面/

打开表按钮click代码

select (select(1))
use ax.dbf
thisform.lockscreen=.t.
thisform.grid1.recordsourcetype=1
thisform.grid1.recordsource="ax"
thisform.lockscreen=.f.

分页按钮click代码

thisform.lockscreen=.t.
close databases
select (select(1))
use ax
goto top
rno=recno()
rc=reccount()
pno=1
pc=iif(rc/5-int(rc/5)>0,int(rc/5)+1,int(rc/5))
if file("axtemp.dbf")
if used("axtemp")
select axtemp
use
endif
delete file ax.temp
endif
copy to axtemp next 5
select (select(1))
use axtemp
thisform.grid1.recordsourcetype=1
thisform.grid1.recordsource="axtemp"
thisform.lockscreen=.f.

 上一页按钮click代码

if pno=1
messagebox("first")
else
thisform.lockscreen=.t.
close databases
select (select(1))
use ax
rc=reccount()
pc=iif(rc/5-int(rc/5)>0,int(rc/5)+1,int(rc/5))
pno=pno-1
rno=pno*5-4
if file("axtemp.dbf")
if used("axtemp")
select axtemp
use
endif
delete file ax.temp
endif
goto (rno)
copy to axtemp next 5
select (select(1))
use axtemp
thisform.grid1.recordsourcetype=1
thisform.grid1.recordsource="axtemp"
thisform.lockscreen=.f.
endif

下一页按钮click代码

if pno=pc
messagebox("last")
else
thisform.lockscreen=.t.
close databases
select (select(1))
use ax
rc=reccount()
pc=iif(rc/5-int(rc/5)>0,int(rc/5)+1,int(rc/5))
pno=pno+1
rno=pno*5-4
if file("axtemp.dbf")
if used("axtemp")
select axtemp
use
endif
delete file ax.temp
endif
goto (rno)
if rc-rno<5
copy to axtemp next (rc-rno)
else
copy to axtemp next 5
endif
select (select(1))
use axtemp
thisform.grid1.recordsourcetype=1
thisform.grid1.recordsource="axtemp"
thisform.lockscreen=.f.
endif

关闭表按钮click代码

close databases

完成
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签:  delete file path c