Not Expected Dynamic Container Results

Hello everyone,

I am running into a scenario that is new to me even though I have been instantiating dynamic containers for a while now. Here is my situation in highlevel and please tell me if this is expected based on my process.

  1. lets say I have “DynContainer” that has two controls on it (Textfield1 and Button1).

  2. Now I instantiate this DynContainer, add positioning properties

  3. I add DynContainer to the DynContainerArray (which is the same type of DynContainer) (*Note: Both DynContainer and DynContainerArray are located under a separate Module)

  4. I Embed DynContainer to “AddCommandsWindow1”

  5. I fill out the textfields of the dynamically instantiated DynContainers on AddCommandsWindow1

  6. THIS WORKS FINE Up to This point as Expected. While “AddCommandsWindow1” is open I pause the IDE and look into the DynContainerArray – I See all of my container properly and more importantly I see each Containers Contents of a Textfield1 and Button1. Works fine.

  7. ** NOT EXPECTED FROM HERE ON ** - I Close “AddCommandsWindow1” (with no code in the close event FYI) and decide to check on my DynContainerArray’s contents again.

  8. All of my Containers are present in the DynContainerArray HOWEVER Each and every element’s Contents are BLANK. I expected to see TExtfield1 and Button1 for each at this point.

So why am I losing my Contents of “TextField1 and Button1” per each DynContainerArray Entry? The only thing I can see as a link is that the DynContainerArray Containers are embedded into the window I did close. Again I wouldn’t expect that to remove my Contents of the those Containers.

Without muddling this example up with code snippets is this expected based on my steps?

Thank you very much in advance everyone.


As a WorkAround I am Hiding the “AddCommandsWindow” instead of Closing it and it works. However I still didn’t expect the actual closing of this window to strip out the contents of my containers loaded in it’s array.

Where is the DynContainer instance being contained? Which window/container? Is this in AddCommandsWindow1?

If it’s in AddCommandsWindow1 I would expect it to go blank when AddCommandsWindow1 closes. The instance has been destroyed regardless that you have a reference to it elsewhere.

DynContainer is also on the module along with the Array and thats why I didn’t expect this to happen when that window closed :slight_smile:

This is the only reference on the Containers AddCommandsWindow

Its definitely the embedwithin(Self) that is causing this.

I am calling this dynamic instantiation on the AddCommandsWindow.Open event. The DynContainer and DynContainerArray ARE not on this window scope wise. But the above image shows the link after I embedwithin(Self).

Right, but what I’m saying is that when you close the window, it’s also destroying the container that’s on the window. That’s what the window is supposed to do.

I don’t see the advantage of what you’re trying to do. When you need the dynamic container again just rebuild it.

Ah ok thanks Bob I will go at it from another angle. Thank you again for helping me understand those reference links.


FWIW, we use containers all the time and I’ve never attempted it the way you’re trying. We keep our reference array on the Window/Container that’s using the container even if we’re using the same container in multiple places.

I’m curious, are you trying to setup the container and then use it in multiple places? If so, I’d create a Factory method that creates the container and sets it up with default values. Then on the end window you embed it and keep the reference (if you need to).

Yes I was trying to re-use it multiple times after I build it (added to it) :slight_smile:

I will try the factory method and thank you again Bob!