I want to clone a set of (two) controls (Label and TextField) and I have trouble doing that.
In UserGuide-UserInterface.pdf, page 108 explain how to do that and share the example below:
Dim pb As PushButton
pb = New PushButton1 //create clone
pb.Caption = "Clone"
pb.Left = Me.Left + Me.Width + 10
That works fine if you really read the page and do as explained.
BUT: I want to be able to dynamically set the number of clones (as part of a larger project). To simulate what I want to do, I used a Loop:
[code]Dim pb As PushButton
Dim i As Integer
for i = 0 to 5
pb = New PushButton1 //create clone
pb.Caption = "Clone " + Str(i)
pb.Left = Me.Left + Me.Width + 10
next
[/code]
the code compiles, but
a. I only saw one clone (the others are certainly below this one),
b. how do I call these to change the caption of the Label (in my code) and the contents of the TextField (still in my code) ?
The same example can be found in new.
BTW: some people will want too see my code, so here it is:
[code]Sub Action(index as Integer)
Dim tf As TextField
Dim L As Label
Dim LoopIdx As Integer
For LoopIdx = 0 to 5
// Create a TextField clone
tf = New TF_Default
// Create a Label clone
L = New L_Default
Next
// Done !
Beep // There is a breakpoint here
End Sub[/code]
In the debugger, I can see that all 6 clones have been created (6 Labels, 6 TextFields).
The question is: how do I set each Label a different Text and the TextFields a different contents; and later, before closing the window, how do I get back the TextFields contents ?