Results 1 to 3 of 3

Thread: How to open new forms in one window?

  1. #1

    Thread Starter
    New Member
    Join Date
    May 2019
    Posts
    2

    How to open new forms in one window?

    I'm trying to create a text based football simulation game, however every time I move from one "form" to the next it keeps opening a new window and the previous "form" remains opened as well.

    How do I make it so there's only one window and I can move back and forth between different forms without new windows opening?

    Name:  Image.png
Views: 204
Size:  38.3 KB

  2. #2
    Super Moderator dday9's Avatar
    Join Date
    Mar 2011
    Location
    South Louisiana
    Posts
    11,801

    Re: How to open new forms in one window?

    What you're describing in the web world is a single-page application pattern. In the desktop world there is no such pattern. You would need to show the form you want and close the form you're finished with:
    Code:
    ' e.g. from Form1:
    Form2.Show()
    Close()
    You start playing around with default instances of Forms when you do it like that so you got to be careful. But I think that's more or less the behavior you're looking for.
    "Code is like humor. When you have to explain it, it is bad." - Cory House
    VbLessons | Code Tags | Sword of Fury - Jameram

  3. #3
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    110,462

    Re: How to open new forms in one window?

    As suggested, you can display a new form and close the previous form each time. If you do that, be sure to configure the app to close after the last form rather than after the startup form.

    The alternative would be to use a single form and then use user controls for each unit of UI. User controls are designed and built much like forms but then used just like other controls. You could create a single form to contain all the user controls, so the user would then not see any forms opening and closing. You could add all the user controls to the form at the same time and then just change the visibility or z-order so they only see one at a time, or you could dynamically create, add and remove them on the form as required.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width