Maximize shape from various C # forms

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

I tried the code below, but it will not work:

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

Any ideas?

+3
source share
2 answers

Well, there are two possible problems: either you are not getting any form, then the solution should show the form.

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

But I assume that you already have form1 loaded somewhere, then you cannot use

Form1 form1 = new Form1();

because then you create a new form that you don’t see, delete this line and find a way to pass a link to form1where it was originally created for the method in which the above code is located.

+11
source
  • :

#

this.WindowState = System.Windows.Forms.FormWindowState.Maximized;

, ;)

0

Source: https://habr.com/ru/post/1761011/


All Articles