Results 1 to 6 of 6

Thread: switch windows form

  1. #1

    Thread Starter
    Member
    Join Date
    Mar 2005
    Posts
    56

    switch windows form

    how can I switch form1 to form2, and closs the form1....

  2. #2
    Super Moderator Shaggy Hiker's Avatar
    Join Date
    Aug 2002
    Location
    Idaho
    Posts
    35,239

    Re: switch windows form

    In the CF? I ask because I prefer to only have a single form for CF apps because of the time it takes to load forms. A better solution, in my opinion is to put panels on a single form, then swap panels in and out of the viewable area. Set the top of each panel to 300, and the left property of each panel to 0. Then when you want to show a panel, set it's top property to 0, voila, it is visible, and it is REALLY fast.

    I believe another technique is to load all forms at the beginning of the program, so that no forms need to be loaded at runtime. If you do that, then you will need to switch forms. If you don't ever need to go back to form1 after you get rid of it, you can close it with Me.Close. If you will need form1 again, then you would want to simply hide it, possibly with something like Me.Hide, or Me.Visible = False. I'm not sure about this, because I think using panels works much better.

    If that doesn't help, I do have a suggestion for swapping forms, but it is more involved, so I'll leave this thread for a bit to see whether anyone else has a simple solution.
    My usual boring signature: Nothing

  3. #3
    Fanatic Member Strider's Avatar
    Join Date
    Sep 2004
    Location
    Dublin, Ireland
    Posts
    612

    Re: switch windows form

    Ya i agree with Shaggy, hiding and unhiding panels is pretty good and fast, the only downside it that if you have a lot of panels with a lot of controls there is a lot lines of code in you class.

    Normally i create and instance of all the most commonly used forms in an application during a splash screen at the startup of the applicaiton, and load any others when appropriate. I use a controller class which i pass into each form, and it this class are methods to display the required form
    Barry


    Visual Studio .NET 2008/Visual Studio .NET 2005/Visual Studio .NET 2003
    .NET Framework 3.0 2.0 1.1/ASP.Net 3.0 2.0 1.1/Compact Framework 1.0

    SQL Server 2005/2000/SQL Server CE 2.0


    If you like, rate this post

    Compact Framework for Beginners

  4. #4
    Super Moderator Shaggy Hiker's Avatar
    Join Date
    Aug 2002
    Location
    Idaho
    Posts
    35,239

    Re: switch windows form

    The lots of lines does get to be an issue. Managing all of the panels on a single computer screen during development is also a problem. The best I can say for the first one is that I REALLY love the ability to use Regions in .NET. That makes managing chunks of code much much nicer. As for the second problem......BIG monitors are nice.
    My usual boring signature: Nothing

  5. #5
    Frenzied Member
    Join Date
    Oct 2005
    Posts
    1,286

    Re: switch windows form

    Hi,
    panels can cause you problems when using devices that allow the user to switch between landscape and portrait, as the unit puts scrollbars on. You need to ensure you set all the panels visible false

    Pete

  6. #6

    Thread Starter
    Member
    Join Date
    Mar 2005
    Posts
    56

    Re: switch windows form

    OK..Thanks...
    I solve my problem by using panel..

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