Dynamic ContainerControl: dynamic add label

  1. 5 weeks ago

    Novice programmer in Xojo... Some experiments with ContainerContol...

    I dynamically create a label:

    dim la as new label
    la.text="test"

    I dynamically create a containercontrol:

    dim tc as new ContainerControl
    tc.HasBackColor=true
    tc.BackColor=Color.Yellow
    tc.Enabled = true
    tc.visible = true
    tc.EmbedWithin(SettingsWindow,0,150,600,200)

    How can I dynamically add the label la to the container tc?

  2. Maurizio R

    Dec 11 Pre-Release Testers, Xojo Pro Answer

    Desktop Control Sets

  3. Maurizio, thank You for your reply! Control Sets seem very strange to me : "Window already contains a control of the type you wish to create... the existing control is used as a template..."

  4. Tim P

    Dec 11 Pre-Release Testers feedback://46303

    @Carlos DBacker Maurizio, thank You for your reply! Control Sets seem very strange to me : "Window already contains a control of the type you wish to create... the existing control is used as a template..."

    That's because you don't want a control set for what you are trying to do. You can't create interface controls, control sets are the only way to use "dim x as new thing" for interface controls, but even then your original code can not work.

    I had posted, but when I tried to quote it for Maurizio, I hit the delete button. Unfortunately, because of this forum software configuration (it didn't behave like this previously, and I'm not happy about the change), you lost out on some valuable information.

    You should describe for us what you're trying to achieve, but from the user's perspective. The community can then help guide you through what technologies you may need.

  5. Maurizio R

    Dec 12 Pre-Release Testers, Xojo Pro

    The rationale behind a controlset is that only already existing controls can be dynamically created and added to a window or container.
    This isn't a strangeness because usually an application often needs to create dynamically more than one control so these controls are grouped in a container control where layout is already defined.
    Adding a single control can be done but a better way is to use a container control.

or Sign Up to reply!