with thisform.myPageFrame.Pages(1).myTextBox .Top = 10 .Left = 10 .Visible = .T. && .F. by default endwith
You can't directly write code at runtime. However starting with VFP6 SP3 you can compile at runtime. So something like this is valid:
text to m.myCode noshow define class myButton as CommandButton Procedure Click messagebox('You clicked a button added at runtime') endproc enddefine endtext
Also there is execscript(). But you should think twice why would you need to that. In most situations you actually know the code to write there in design time but have a sense as if you need to do it at runtime. At design time having classes with skeleton code that accepts parameters are generally the answer.
Use the Addobject method, i.e., Form1.Pageframe1.Page1.AddObject("myGrid","Grid"). Note that you will also have to set the properties of the newly added controls programmatically if you want to position the control.
Help me ! How to add controls to Pageframe at runtime ?
Espen Ruud Schultz
Check NewObject method (AddObject in older versions). ie:
thisform.myPageFame.Pages(1).NewObject('myTextBox','Textbox')
with thisform.myPageFrame.Pages(1).myTextBox
.Top = 10
.Left = 10
.Visible = .T. && .F. by default
endwith
You can't directly write code at runtime. However starting with VFP6 SP3 you can compile at runtime. So something like this is valid:
text to m.myCode noshow
define class myButton as CommandButton
Procedure Click
messagebox('You clicked a button added at runtime')
endproc
enddefine
endtext
StrToFile(m.myCode, "mybuttonclass.prg")
compile myButtonClass.prg
...NewObject('myNewButton', 'myButton', 'myButtonClass.prg')
Also there is execscript(). But you should think twice why would you need to that. In most situations you actually know the code to write there in design time but have a sense as if you need to do it at runtime. At design time having classes with skeleton code that accepts parameters are generally the answer.
Mongsreturn
TonyCapps
RWF
You can also add these to the form in design mode and make the Visible property .f. When you need it just change it back to .t.
I find that much simpler that creating an object each time.