3

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?

4

2 回答 2

11

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.

于 2010-08-22T18:52:26.387 回答
0
  1. 转到将表单或按钮加载为查看代码并使用此代码:

C#

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

我希望它对你有用;)

于 2015-12-03T10:33:01.540 回答