Reputation: 463
I have two forms, Form1 and Form2. I currently have a button in the startup form(Form1) that loads up Form2. What I would like to do is have Form1 become minimized and only show Form2 once it is told to load so that Form1 is not in the background while Form 2 is shown.
So far I have tried things such as:
this.WindowState = FormWindowState.Minimized;
but the problem I'm having is that it causes Form2 to become minimized as well. Is there a way to specifically cause only Form1 to be affected or work around this problem?
below you will find my code, I may have made some mistakes!
Form2 add = new Form2();
this.WindowState = FormWindowState.Minimized;
add.ShowDialog();
I had also tried putting the windowstate behind the showdialog but it may not work because it will only execute after the dialog is done working.
Upvotes: 4
Views: 4528
Reputation: 8224
Your issue is due to two things.
Change your code to this:
var add = new Form2();
add.Show();
WindowState = FormWindowState.Minimized;
Upvotes: 4