How to reference the ContainingPanel?

I’m attempting to use EmbedWithinPanel to embed a container control within a TabPanel. This is the definition from the docs:

[quote]ContainerControl.EmbedWithinPanel(ContainingPanel as PagePanel, Page as Integer, [left as Integer], [top as Integer], [width as Integer], [height as Integer])
Embeds the ContainerControl on a page in the passed PagePanel or TabPanel.[/quote]

The example given is…

[code]MainTab.AddPanel(“New Tab”)
Var tabNum As Integer
tabNum = MainTab.PanelCount - 1

Var cc As New MyContainer
cc.EmbedWithinPanel(MainTab, tabNum)[/code]

But what if you don’t know the name of the ContainingPanel? In the example, the TabPanel is called, ‘MainTab’ but what if you’re creating a custom control that will be placed on a TabPanel that you don’t yet know the name of?

I created a ContainerControl called, ‘myProgressWheel’. I put a ProgressWheel into it.

I sub-classed PopupMenu and called it myPopupMenu. I added a property…

Public Property Wheel as myProgressWheel

And I added an event to place the container with the progress wheel in it just to the right of the menu…

Sub Open() Handles Open Wheel = New myProgressWheel Wheel.EmbedWithinPanel(Me.Parent, Me.PanelIndex, Me.Left+Me.Width+12, Me.Top, Me.Height, Me.Height) End Sub

I dragged a TabPanel into Window1 and it created TabPanel1.

I dragged a myPopupMenu into TabPanel1 to create myPopupMenu1.

Since Me.Parent.Name returns “TabPanel1”, I expected Me.Parent to equate to the containing control as a TabPanel that I could use in EmbedWithinPanel but instead, it returns a RectControl.

How do I get the TabPanel?

Cast it to a TabPanel.

Wheel.EmbedWithinPanel(TabPanel(Me.Parent), page, …

That did it. Thanks!