Is there a way to swap different types of ContainerControls?
I have a project where I have a listbox as a project browser.
Somewhere else I have a PagePanel with two pages. When there is no selection in the listbox, page 0 is displayed. When there is a selection, page 1 is displayed. This way I have a nice clean window, when nothing is selected. Only a label is shown "Select an item in the browser".... or something like that...
When there is a selection I check what type of panel should be displayed. I have stored that somewhere in the RowTag in the listbox.
Now I have a bunch of panels
- ProjectData panel, to show/edit project settings
- ClientData panel, to show/edit client's details
- MediaData panel, to show a list of media... like some sort of media library
...and so on.
The thing is, that I want to swap the panel according to what I have selected in the list (browser).
I don't want instances of these panels laying around when not in use. I did try to add more pages to the PagePanel control. But this way I had too many instances.
So, I close them when I change to another panel. But when I re-open a panel I got an error that I cannot embed a closed ContainerControl. So, somehow I need to re-instantiate the panel, right?
But re-instantiating a control at run-time is not possible... as far as I know.
In my listbox I assign a class to the rowtag. In this class I have properties like
- Panel --> this is where I can store an instance of the Container Control (but this keeps too many instances "alive")
- dataType --> this is to identify the type of data the browser-item represents. So, when selecting it, I know what kind of data I have to pull from my database.
- recordID --> in case a browser item refers to a record in my database.
...and some other properties I need
It would be nice to add a windowProperty as ContainerControl named "CurrentPanel"
And do something like this:
Embed this property in the PagePanel.
CurrentPanel = new ContainerControl( mySelectedPanel )
or something like that...