OK...a couple of things. You don't want to re-write this code over and over again so this logic should be placed in your BaseForm. All of your maintenance forms will inherit your BaseForm which inherits from our StandardForm:Public Class MyBaseForm
Inherits MicroFour.StrataFrame.UI.Windows.Forms.StandardForm
End Class
Next, you will probably just always allow that themed container to be on the side panel, just change its visibility and place it as well as any other items in a FlowLayoutPanel. This way when you change their sizes and visibilities the other controls will automatically adjust themselves in respect to the controls being changed.
Finally you will need to create a shared reference to that object and/or create a shared event that is managed by application. You can go a lot of different ways on the event in regards to who manages what. For example, you could create a shared event that the ThemedContainerClass that will be in the panel manages. Conversly you could create an event that is managed by the form which forces the logic to execute. If you just want to go down the object route, then create a shared reference to the themed continer and then in your base form add your logic:
Public NotInheritable Class MyBasics
Private _PanelContainer As ThemedContainer
Public Property SidePanelContainer as ThemedContainer
Get
Return _PanelContainer
End Get
Set(Byval value as ThemedContainer)
_PanelContainer = value
End Set
End Property
End Class
Set this property in your application once the object has been created. It could be in the panel itself it necessary:
MyBasics.SidePanelContainer = Me
Finally, add your logic in your base form to update the container:
Overrides Protected Sub OnLoad(...)
MyBase.OnLoad(...)
MyBasics.SidePanelContainer.Visible = True
End Sub
Overrides Protected Sub OnFormClosing(...)
'-- Add your logic to see if the container should be removed
MyBasics.SidePanelContainer.Visible = False
MyBase.OnFormClosing(...)
End Sub