Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Maximize Form from differient form C#

Does anyone know how to maximize a form from another form, in c#?

I tried the code below but it won't work:

Form1 form1 = new Form1();
form1.WindowState = FormWindowState.Maximized;

Any ideas?

like image 986
Shane121 Avatar asked Oct 15 '25 08:10

Shane121


1 Answers

Well two possible problems, either you don't get any form at all, then the solution is to Show the form.

Form1 form1 = new Form1();
form1.WindowState = FormWindowState.Maximized;
form1.Show();

But I guess that you already have a form1 loaded somewhere, then you can not use

Form1 form1 = new Form1();

because then you creates a new form that you don't display, remove this line and find a way to pass a reference to form1 from where it was originally created to the method where the above code is located.

like image 119
Albin Sunnanbo Avatar answered Oct 16 '25 22:10

Albin Sunnanbo



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!