回复 3楼 吹水佬
感谢你的提示,让我多学了一招“查看父代码”
但问题是,在百度里,可以搜到“第一条、上一条、下一条、最后一条”这样的按钮组代码,虽然那不是针对多表联动的,但至少可以得到一定的思路
而搜“vfp按钮组添加的代码”之类的,根本搜不到,翻了几本书,也没有细致讲解的
总结一个字,
写书的人,太扣门了,传授知识很吝啬啊!
——————————————————————————————————
父代码,例如“添加”的
IF THIS.Parent.EditMode
THIS.Parent.UpdateRows()
ELSE
IF !THIS.Parent.AddRec()
RETURN
ENDIF
ENDIF
THIS.Parent.EditMode = !THIS.Parent.EditMode
THIS.Parent.AddMode = THIS.Parent.EditMode
THIS.Parent.TopFile = .F.
THIS.Parent.ButtonRefresh()
THIS.Parent.NavRefresh()
————————————————————————————————————————
表单的继承方法
#DEFINE C_NOUPDATE_LOC
"你不能添加新纪录,因为该选定的视图不能发送更新。"
#DEFINE
DIALOG_CLASSLIB "WIZBTNS.VCX"
LOCAL lnSaveRec,lcSaveData,loAddRec,loCustom,cPrimaryKey,lcClassLib,nPrimaryKey
IF EOF() OR BOF()
GO TOP
ENDIF
lnSaveRec = RECNO()
DO CASE
CASE FILE(DIALOG_CLASSLIB)
lcClassLib = DIALOG_CLASSLIB
CASE FILE(HOME()+"WIZARDS\"+DIALOG_CLASSLIB)
lcClassLib = HOME()+"WIZARDS\"+DIALOG_CLASSLIB
OTHERWISE
lcClassLib = ""
ENDCASE
DO CASE
CASE CURSORGETPROP("SourceType")#3 AND ;
!CURSORGETPROP("offline") AND ;
!CURSORGETPROP("SendUpdates")
MESSAGEBOX(C_NOUPDATE_LOC)
RETURN .F.
CASE EMPTY(CURSORGETPROP("database"))
* Free table
APPEND BLANK
CASE CURSORGETPROP("SourceType")#3
* View
APPEND BLANK
CASE CURSORGETPROP("buffering")#1 AND !THIS.lPromptKey
* buffered data
APPEND BLANK
CASE EMPTY(lcClassLib)
* could disable this if you feel
* potential unique ID conflicts could arise
APPEND BLANK
OTHERWISE
lcSaveData = SET("DATABASE")
SET DATABASE TO CURSORGETPROP("database")
cPrimaryKey = DBGETPROP(CURSORGETPROP("sourcename"),"Table","PrimaryKey")
nPrimaryKey = TAGNO(m.cPrimaryKey)
SET DATABASE TO &lcSaveData
IF EMPTY(cPrimaryKey) OR m.nPrimaryKey=0
APPEND BLANK
ELSE
cPrimaryKey=KEY(m.nPrimaryKey)
loAddRec=NewObject("AddRecord",lcClassLib,"")
loCustom = Create('custom')
loAddRec.cKeyField = m.cPrimaryKey
loAddRec.cKeyValue = EVAL(m.cPrimaryKey)
loAddRec.oRetValue = loCustom
loAddRec.Show()
IF loCustom.nBtnAction=1
INSERT INTO (ALIAS()) ((m.cPrimaryKey)) VALUES(loCustom.cKeyValue)
ELSE
THIS.HadError = .T.
ENDIF
ENDIF
ENDCASE
IF THIS.HadError
THIS.HadError = .F.
GO lnSaveRec
RETURN .F.
ENDIF
THISFORM.Refresh()
——————————————————————————————
向导生成的按钮组的继承方法:
略
[此贴子已经被作者于2015-10-27 09:40编辑过]