container control question

  1. 4 years ago

    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?

    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()
  2. Michel B

    23 Dec 2016 Testers, Xojo Pro

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

  3. Edited 4 years ago

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

  4. Gavin S

    23 Dec 2016 Testers, Xojo Pro, Forum Moderators, MVP Answer UK

    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()
  5. @Gavin S works great. thanks a lot

  6. Michel B

    23 Dec 2016 Testers, Xojo Pro
    Edited 4 years ago

    @nicoláscanessa thanks Michael Bujardet but i have read a lot and i can't find a way

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

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

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

  7. 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...

  8. 3 years ago

    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!

  9. Tim H

    22 Oct 2017 Portland, OR USA

    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)
  10. 2 weeks ago
  11. Clifford C

    Jun 28 Port Angeles, Washington

    @Tim H 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)

    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.

  12. Tim S

    Jun 28 Testers Canterbury, UK

    can't you do:

    cc.show()

    ?

  13. Clifford C

    Jun 28 Port Angeles, Washington

    @Tim S can't you do:

    cc.show()

    ?

    It was bad code of mine Tim. Your answer was correct. Thanks

or Sign Up to reply!