Running a a form from a form
I have 2 classes:
public class Form1 : System.Windows.Forms.Form
public class Form3 : System.Windows.Forms.Form
--------------------------------------------
Main() starts Form3 (simple yes, no label):
static void Main()
{
Application.Run(new Form3());
}
--------------------------------------------
For the YES button I have the other form I want to run and close the Form3.
private void YES_Click(object sender, System.EventArgs e)
{
Application.Run(new Form1);
Application.Exit();
}
--------------------------------------------
When I run this and press YES an error box pops up that says:
An unhandled exception of type 'System.InvalidOperationException' occurred in system.windows.forms.dll
Additional information: It is invalid to start a second message loop on a single thread. Use Application.RunDialog or Form.ShowDialog instead.
--------------------------------------------
When I try to use Form.ShowDialog it won't compile and says it needs an object.
When I try to use Application.RunDialog it says it is unaccessable due to its protection level.
What should I do?
I have 2 classes:
public class Form1 : System.Windows.Forms.Form
public class Form3 : System.Windows.Forms.Form
--------------------------------------------
Main() starts Form3 (simple yes, no label):
static void Main()
{
Application.Run(new Form3());
}
--------------------------------------------
For the YES button I have the other form I want to run and close the Form3.
private void YES_Click(object sender, System.EventArgs e)
{
Application.Run(new Form1);
Application.Exit();
}
--------------------------------------------
When I run this and press YES an error box pops up that says:
An unhandled exception of type 'System.InvalidOperationException' occurred in system.windows.forms.dll
Additional information: It is invalid to start a second message loop on a single thread. Use Application.RunDialog or Form.ShowDialog instead.
--------------------------------------------
When I try to use Form.ShowDialog it won't compile and says it needs an object.
When I try to use Application.RunDialog it says it is unaccessable due to its protection level.
What should I do?