Container Control

I am trying to use a container control (I’ve never done it before!).
I insert a container control from library to my project; I put inside it a TextField and a Label.
Then I drag my container control onto a window, and I correctly see my Label and my TextField, but I can’t modify them.
Am I doing anything wrong? Or am I missing anything?
Thanks to all.
Nedi

You can only modify the controls it contains, in the container control editor
Think of a container control as a special kind of window.
You design a window in the editor and when it is displayed, you cannot drag the controls around.

Thank you, Jeff.
My intention was to create a custom control consisting of label and textfield, but which could both be editable once dragged onto the window.
Evidently container control is not the right approach.
Do you have any suggestions for me?
Thank you!

What do you mean by editable?
if you want to drop the label and textfield on a window, and then move them relative to each other, use a label and a text field.

If you place them in a container, yopu can arrange them RELATIVE TO THE CONTAINER area
So one may be aligned top, the other bottom
One may be aligned left, the other right

Then when the container is on a window, if you resize it, the contents will move inside the area according to the alignments you used.
The textbox may always be at the bottom for example, but the gap between them will vary according to the height of the finished container on screen

Ok, thank you!

you need to set the anchors in the container control for textbox and label.
you can add computed propertys (in your container control) and read/write your text and label caption.
via context menu inspector behavior you can make this propertys visible in the ui designer.
your container control is more or less a template. if you modify it will replace the current container control u used in the window.

Thank you, Markus!
When I drag the container control onto a window can I modify the properties of the controls it contains? In other words: can I set the width of the textfield, or the text of the label?

[quote=472420:@Nedi Freguglia]Thank you, Markus!
When I drag the container control onto a window can I modify the properties of the controls it contains? In other words: can I set the width of the textfield, or the text of the label?[/quote]

via computed property, yes. and then show this via inspector behavior.
i will make a screen video of it.

Thank you again, Markus.

or you can read my recent blog post about using container controls

@Nedi Freguglia — When you create a ContainerControl, that control basically becomes a closed ecosystem, i.e. you cannot access individual parts of it!

If you want any method to be able to interact with your ContainerControl, you need to create some methods which will, in turn, communicate with the actual objects (i.e. Controls) inside your ContainerControl.

Thank Norman and Stphane: now I know that I can’t do what I had in my mind.

depends on what specifically you wanted to do ?
what is it you wanted to be editable about the label and textfield ?

I would like to modify the properties of both the controls that are in the container, as they where dragged from the library onto the window.
See the thread “User Input Controls should have Captions instead of Labels” of three days ago (I don’t know how link it here!)

[quote=472472:@Nedi Freguglia]I would like to modify the properties of both the controls that are in the container, as they where dragged from the library onto the window.
See the thread “User Input Controls should have Captions instead of Labels” of three days ago (I don’t know how link it here!)[/quote]
You can do this with computed properties and making them visible in the inspector. The only catch is that you don’t get to see the values in the layout editor during design time; but that’s not the end of the world for being able to create custom controls like that!

I’m not sure if there’s a blog post on how to do this.

[quote=472473:@Tim Parnell]
I’m not sure if there’s a blog post on how to do this.[/quote]
there might be like the one I referenced above :slight_smile:

Oh I see it now toward the end! Guilty of skimming :stuck_out_tongue:

here is my video about container control with label and textfield.
Youtube
unfortunately there is no preview in the designer after you set own properties.
in the middle of the video i try to set a caption width so if you have many controls in a column you can change the label width.

btw from source code you can access the inner controls like this

ContainerControl11.TextField1.Value = "Hello"

Here’s the User Guide topic with videos for reference:

https://documentation.xojo.com/topics/user_interface/desktop/desktop_controls/container.html_Control

[quote=472472:@Nedi Freguglia]I would like to modify the properties of both the controls that are in the container, as they where dragged from the library onto the window.
See the thread “User Input Controls should have Captions instead of Labels” of three days ago (I don’t know how link it here!)[/quote]

Perhaps what you need is not a container control, but subclasses.