ContainerControl.EmbedWithin

From Xojo Documentation

Method

ContainerControl.EmbedWithin(ContainingWindow as Window, [left as Integer], [top as Integer], [width as Integer], [height as Integer])

Supported for all project types and targets.

Embeds the ContainerControl in window ContainingWindow.

Notes

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.


Method

ContainerControl.EmbedWithin(Container as RectControl, [left as Integer], [top as Integer], [width as Integer], [height as Integer])

Supported for all project types and targets.

Embeds the ContainerControl in the specified Container control.

Notes

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.

General Notes

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.

Sample Code

This code is in the Action event of a button and add a container control to a window:

Var tc As New TestContainer
tc.EmbedWithin(Self, 10, 100, 300,400)

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.

// Add the container
MyContainer = New TestContainer
MyContainer.EmbedWithin(Self, 10, 100, 300, 400)

Elsewhere you can remove the container:

MyContainer.Close