0

Simple question:

I used Application.Run to start my application because I need it this way.

Now I want to add a form later in the code. But it doesn't open the form if I use new Form1. Instead it runs everything else in the constructor of the class Form1. So somehow it ignores to open the form.

3
  • You mean you want to call the opened Form1? Commented Sep 25, 2017 at 8:57
  • you also have to show it, (new Form1()).Show(); Commented Sep 25, 2017 at 8:57
  • Possible duplicate of opening a window form from another form programmatically Commented Sep 25, 2017 at 10:30

1 Answer 1

2

Just newing up a form makes it exist in memory but does not display anything.

You have to show it:

// create instance of Form1, does not show it
var myForm = new Form1();
// show the form.
myForm.Show();

see msdn documentation

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.