Move containerControl between windows

Hi,

I have a window with some containerControls as tabs.

I want to make one tab (containerControl) independent in a new window.

All what I get is that my containerControl has disappeared from both windows, and in the Debugger, the window property of containerControl has assigned the correct one (the new window).

I add the containerControl in the first window with the EmbedWithin option, and later, I use the same method (EmbedWithin) but with the new window reference.

If I first close the containerControl before moving it to the new window, it dissappears completely.

I simply can’t create a new container as those containers has unsaved data there …

Maybe is not supported this functionality ?

thanks,

Could you maybe show some sample code of what you’re trying to do?

I’m not sure I understand why you can’t copy the unsaved data in the constructor or open event of window2

Dim cc as new containercontrol
cc.myTextArea.Text = Window1.ccOriginal.myTextArea.Text

cc.EmbedWithin(Self, 0,0)

well, they are very complex containers with lots of objects, it will be too much work …[quote=45804:@Jym Morton]I’m not sure I understand why you can’t copy the unsaved data in the constructor or open event of window2

Dim cc as new containercontrol
cc.myTextArea.Text = Window1.ccOriginal.myTextArea.Text

cc.EmbedWithin(Self, 0,0)[/quote]

well, they are very complex containers with lots of objects, it will be too much work …

ok, on first window, I add a new container called cToMove

app.container = new cToMove app.container.EmbedWithin(self,0,0)

In the same window, I have a button that tries to move this container to another window

Dim w as new Window2 app.container.EmbedWithin(w,0,0)

Unfortunately, that is not going to work. An instance of a ContainerControl can only be embedded into a single object.

It sounds like you may want to implement a “copy constructor” on your ContainerControl that copies over all the required values to a new ContainerControl.

[quote=45857:@Paul Lefebvre]Unfortunately, that is not going to work. An instance of a ContainerControl can only be embedded into a single object.

It sounds like you may want to implement a “copy constructor” on your ContainerControl that copies over all the required values to a new ContainerControl.[/quote]
It would be great that existed an unembedded method

:slight_smile:

Maybe I should file a feature request …

The copy constructor can be very tedious as I have lots of complex objects that simply can’t be referenced, must be copied also …

But in my example, the ContainerControl is embedded into a single object, I want to move from one object to another, I don’t want to stay embedded in two objects at the same time…

That’s not what he meant. A container instance can only be embedded once.

You need to create a custom class to store your data, and pass that class instance between the windows. Have each container control read/write the data from your class instance.