动态加载一个控件,如按钮,并给按钮的Click事件绑定事件:
1、建一个过程文件(如MyProc.PRG),内容如下
Define Class myhandler As Session
Procedure CmdClick
Messagebox('ok',64,'') &&此处改为你的相应代码
Return
Endproc
Enddefine
2、表单的INIT事件:
Set Procedure To MyProc.prg
3、表单上动态加载控件按钮的CLICK事件:
Thisform.AddObject('Cmd_Test','CommandButton')
Thisform.Cmd_Test.Caption='Cmd_Test'
Thisform.Cmd_Test.Top=100
Thisform.Cmd_Test.Left=100
Thisform.Cmd_Test.Height=25
Public oHandler
oHandler=Newobject("myhandler")
Bindevent(Thisform.Cmd_Test,"Click",oHandler,"CmdClick")
Thisform.Cmd_Test.Visible=.T.
联系客服