Add Object dd as commandbutton Withor
Add Object dd form1. as commandbutton With
试试
form1 为表单的name属性值
dd 为控件名
使用for循环添加的时候
dd不能为重复的
个性太多,无法显示
************************************************** *-- Form: form1 (e:\tc\lcz\0921\js_dn\qqqqq.scx) *-- ParentClass: form *-- BaseClass: form *-- 时间戳: 09/24/12 02:34:08 PM * DEFINE CLASS form1 AS form DoCreate = .T. Caption = "Form1" Name = "Form1" ADD OBJECT container1 AS container WITH ; Top = 24, ; Left = 84, ; Width = 241, ; Height = 120, ; Name = "Container1" ADD OBJECT form1. AS commandbutton WITH ; Top = 60, ; Left = 108, ; Height = 25, ; Width = 60, ; Caption = "Command1", ; Name = "Command1" ADD OBJECT command1 AS commandbutton WITH ; Top = 192, ; Left = 240, ; Height = 25, ; Width = 60, ; Caption = "Command1", ; Name = "Command1" PROCEDURE command1.Click thisform. = 'ad' ENDPROC ENDDEFINE * *-- EndDefine: form1 **************************************************
Clear All Main() Procedure Main() Local lo_MainForm lo_MainForm = NewObject("C_Form") lo_MainForm.Show Read Events Return EndProc Define Class C_Form as Form Width = 400 Height = 400 AutoCenter = .T. Caption = "Experiment" Procedure Init With this .AddObject("oo", "Label") .AddObject("xx", "CommandButton") With THis.xx .Top = 230 EndWith BindEvent(.xx, "Click", this, "Click1" ) .SetAll("Visible", .T.) .SetAll("Left", 100) .SetAll("Width", 100) .SetAll("Height", 100) .SetAll("BackColor", Rgb(234, 4,45)) EndWith ThisForm.xx.Caption = "xxxx" ThisForm.oo.Caption = "yyyy" EndProc Procedure Click1 MessageBox("八戒。。。") EndProc *!* Procedure xxxx.Click *!* MessageBox("悟空。。。") *!* EndProc Procedure destroy Clear Events EndProc EndDefine如果不把xxxx的悟空 注释掉 会这样
dd = Newobject("ws") dd.show Read events Return DEFINE CLASS ws AS form DoCreate = .T. Caption = "Form1" Name = "Form1" ADD OBJECT container1 AS container WITH ; Top = 24, ; Left = 84, ; Width = 241, ; Height = 120, ; Name = "Container1" ADD OBJECT command1 AS commandbutton WITH ; Top = 192, ; Left = 240, ; Height = 25, ; Width = 60, ; Caption = "Command1", ; Name = "Command1" PROCEDURE command1.Click thisform. = 'ad' ENDPROC PROCEDURE container1.init && 给容器添加对象 this.AddObject("command1","commandbutton") (60,50,60,25) = .t. bd = 0 For i = 1 To 5 tt = 'text' + Transform(i) this.AddObject(tt,"textbox") this.&tt..move(bd,0,20,25) this.&tt..visible = .t. bd = bd + 21 Next Endproc ENDDEFINE * *-- EndDefine: ws **************************************************