PDA

Click to See Complete Forum and Search --> : switch windows form


simoms
May 2nd, 2006, 10:04 AM
how can I switch form1 to form2, and closs the form1....

Shaggy Hiker
May 2nd, 2006, 10:19 PM
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.

Strider
May 3rd, 2006, 03:50 AM
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

Shaggy Hiker
May 4th, 2006, 10:17 PM
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.

petevick
May 6th, 2006, 12:47 PM
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

simoms
May 10th, 2006, 09:33 AM
OK..Thanks...
I solve my problem by using panel..