Programatically add a control

If I want to add a label dynamically to a window (desktop) I can find a good example.
I think I have to do a containercontrol then add it to that.
Is this the way to do it?
Does anyone have a code snippet??

For something like a label, I think a Control Set would be better than a ContainerControl. Put a label on the window, say, Label1. Select it and click the gear icon in the inspector. Make it Member Of -> New Control Set. Now you can add a new Label1 to the window with code like:

dim l as Label = new Label1
l.Left = x
l.Top = y
l.Text = "New label"

Hamish,
I Agree with Tim, Control Set would be the better and more flexible option.

  1. in addition to what Tim suggested you might create the label and set it to invisible (label1.visible =FALSE), then add programmatically:
dim nicelabel as label1
nicelabel = new label1
nicelabel.left = x
nicelabel.top=y
nicelabel.visible=TRUE

you also have a 2nd simpler option, if the case.
So, if you just need one label, you can put it where you want on the window and then set the visible property to FALSE. When you need it to be shown , then set the label visible property to TRUE.