Click to See Complete Forum and Search --> : a very simple question
Ixl2
Nov 25th, 2005, 04:47 AM
Hi
While im teaching myself C# ive come across a small problem that is:
How do i close one form and open the 2nd form in my test app? :eek:
I know thats a n00b question but i've not worked it out for myself?
Ixl2
Nov 26th, 2005, 11:24 AM
*Bump*
Any help please guys cannot seem to get this basic question answered at all
EDIT:
I worked out how to open form2 just need to work out how to close form one when form2 is open
tr333
Nov 26th, 2005, 09:30 PM
if you have the application set to run Form1 on startup, when you close this form the whole application will close. you need to set the application to run from the Main() function. in that function you can do:
Form frm1 = new Form1();
Form frm2 = new Form2();
Application.Run(frm1);
Application.Run(frm2);
there might be easier ways than that... you could just hide the form incase you want it to reappear later.
jmcilhinney
Nov 27th, 2005, 04:18 AM
If you're using C#2005 you can seta project property so that the app does not exit until all forms are closed instead of when the startup form closes. If you're using C# 2003 you can provide this behaviour yourself but it is a pain in the butt. I've provided a submission in the CodeBank that allows you to switch main forms as long as the new main form is created at the time. The code is VB.NET but there's a link to a code converter in my sig.
Ixl2
Nov 27th, 2005, 05:29 AM
Thanks for the repliys
What ive done a tmp thing is set form to hide while form 2 is running, but ill look into both your ways and see which is easy.
Thanks
vbforums.com
Copyright Internet.com Inc., All Rights Reserved.