我经常这样做:
(1)在FORM1的INIT中写上这样的命令
CLOSE ALL
USE 表1.DBF
THISFORM.GRID1.RECORDSOURCETYPE=1
THISFORM.GRID1.COLUMNCOUNT=-1
THISFORM.GRID1.RECORDSOURCE="表1"
(2)假如点击表格GRID1中的一行后就执行删除,则在THISFORM.GRID1.AFTERROWCOLCHANGE过程中书写代码:
IF MESSAGEBOX("删除吗",36,"提示")=6
THISFORM.GRID1.RECORDSOURCE=NULL
DELETE
PACK
THISFORM.GRID1.RECORDSOURCE="A"
ENDIF
THISFORM.REFRESH
(3)若需要根据某字段的值且点击删除命令按钮后执行删除,则在该命令按钮的CLICK过程中书写代码:
LOCATE ALL FOR <字段名1>=THISFORM.TEXT1.VALUE
IF EOF()
MESSAGEBOX("无法删除不存在的记录",0,"提示")
ELSE
IF MESSAGEBOX("删除吗",36,"提示")=6
THISFORM.GRID1.RECORDSOURCE=NULL
DELETE
PACK
THISFORM.GRID1.RECORDSOURCE="A"
ENDIF
ENDIF
THISFORM.REFRESH