container control question

i have a container control, a window and two buttons: “show container” and “hide container”
to show a container i use this code:

Dim tc As New containercontrol1 tc.EmbedWithin(Self, 200, 100)

how do i hide the container control? how do i close it?
is there a simple code that i could put into the “hide container” button?

http://documentation.xojo.com/index.php/Containercontrol

thanks Michael Bujardet but i have read a lot and i can’t find a way

You simply use the Close method on the container. However, you need to get a reference to the container so that both buttons can refer to it. At the moment, only your Show button knows what tc is.

So, make tc a property of the Window, with type ContainerControl1.

In the Show button:

tc = new ContainerControl1 tc.embedWithin(self, 200, 100)

In the Hide button:

tc.close()

@Gavin S works great. thanks a lot

Hide ? Close ? You did not find these two methods on the page ? Give me a break …

http://documentation.xojo.com/index.php/Window.Hide

http://documentation.xojo.com/index.php/Window.Close

thanks michael but I think you have not understood what my doubt was. the answer to my question is “you need to get a reference to the container so that both buttons can refer to it”
i’m not an expert. i’m still learning every day…

Sorry for bringing up an old thread. I did not want to create a new one. What I could not find in the Xojo documentation is when the “Open” event of a Container Control fires.

When working with Container Controls, I usually create a reference first, then embed it so it becomes visible.

DIm cc As New ContainerControl1 cc.EmbedWithin(Window(0),0,0)

Now when I close it later with

cc.Close

and I want to re-open it, do I have to use EmbedWithin again or just cc.Visible = True? If it’s the latter, will the Container Control’s “Open” event fire again?

Thank you!

You need to create a new one. Once you Close it, it’s not reusable. But to answer your question

Dim cc As New ContainerControl1    <<--- Open Event happens here
cc.EmbedWithin(Window(0),0,0)

[quote=355642:@Tim Hare]You need to create a new one. Once you Close it, it’s not reusable. But to answer your question

Dim cc As New ContainerControl1 <<--- Open Event happens here cc.EmbedWithin(Window(0),0,0) [/quote]

Tim, if you hide the containerControl you would be able to refer to it’s stored properties. I can hide these controls but have not found a method to unhide them that works. I can close it and create another one but I was hoping to use the container control to store information.

can’t you do:

cc.show()
?

[quote=494267:@Tim Streater]can’t you do:

cc.show()
?[/quote]
It was bad code of mine Tim. Your answer was correct. Thanks