Dynamic control and Constructor

I have a window with a single member controlset [textfield(0)]
the purpose is to dynamically add and position more textfields as the app requires at runtime.
This all works fine… EXCEPT if I try to create a CONSTRUCTOR that passes a value

this works

dim temp as new myTextfield
temp.caption = "something"

this does not [the control never appears]

dim temp as new myTextField("something")
// where the constructor contains [me.caption=value, and value is an argument of the constructor]

am I doing something “wrong”? or is this a bug {API1.0}

and yes VISIBLE=true

Stupid question: are-you sure they do not appears at the same x,y with the same w,h ?
(you get a pile where only one appears…)

I’ve done that recently, but set x,y (and other stuff) immediately after adding a brand new one.

The controls appear properly (correct location etc) if I DO NOT attempt to pass anything via the Constructor

I can have a constructor, and set values within it, but it fails to show (no errors) if I pass a parameter

Viewing the control in the debugger looks fine… .it just doesn’t show up

controls with constructors are … a pain … simply because of how they must work to be placed in a layout (windows or CC at design time AND at runtime)


To be able to put them in a layout at design time they require a no param constructor
But, like youre trying, its useful to want to have a a parameterized constructor

have a read of that article which may give you some insight into how to make this work better

My guess is that in your constructor the caption parameter is getting set before the field itself is completely built. Can you set a local property, say ‘mCaption’, to the parameter and then assign mCaption to the Caption in the Open (Opening :wink: ) event handler?

I just made it simple… I added the one parameter as public (I wanted it private, which could have been handled by the constructor)… then just set it after I instantiated the control

The stuff in Norms post (thanks) was too much to duplicate for 12 different subclassed control types