Reputation: 15446
I used two forms in my windows application that they aren't my main form. Now I want to close form1 and open form2. How to I do this. Thanx.
Upvotes: 0
Views: 2822
Reputation: 3738
I did this once for my project, to close one application and open another application.
System.Threading.Thread newThread;
Form1 frmNewForm = new Form1;
newThread = new System.Threading.Thread(new System.Threading.ThreadStart(frmNewFormThread));
this.Close();
newThread.SetApartmentState(System.Threading.ApartmentState.STA);
newThread.Start();
And add the following Method. Your newThread.Start will call this method.
public void frmNewFormThread)()
{
Application.Run(frmNewForm);
}
Upvotes: 1
Reputation: 49978
Take a look at Hiding and Showing Forms for a good example of various techniques.
Major points include:
Upvotes: 4