From Xojo Documentation
Embeds the ContainerControl in window ContainingWindow.
The optional Left and Top parameters determine the location of the top-left corner, relative to the containing window. The optional parameters Width and Height determine the size of the embedded ContainerControl.
Embeds the ContainerControl in the specified Container control.
The ContainerControl is embedded on the passed control (which becomes the parent of the ContainerControl). If the ContainerControl is embedded on a PagePanel or TabPanel, it is embedded on the current page. However, you should use EmbedWithinPanel for this purpose instead as it allows you to specify the page.
The optional Left and Top parameters determine the location of the top-left corner, relative to the containing control. If the ContainerControl itself has Left and Top values (not typical as they default to 0) then they are added to what is specified here. The optional parameters Width and Height determine the size of the embedded ContainerControl.
An instance of a ContainerControl can only be embedded into one object.
If you want to dynamically embed containers into each other, make sure that you first embed the containers that you wish to use as a source for other containers. Failure to do this will result in a run-time error.
This code is in the Action event of a button and add a container control to a window:
If you need to later remove the container, then you'll need to have a reference to it. In this case, use a property for the container. Add the container using EmbedWithin and remove it using Close.
Elsewhere you can remove the container: