在我的c#表单项目中,我希望每次加载任何表单时都会运行此方法。
foreach (Form frm in Application.OpenForms)
{
frm.WindowState = FormWindowState.Normal;
frm.FormBorderStyle = System.Windows.Forms.FormBorderStyle.None;
frm.Bounds = Screen.PrimaryScreen.Bounds;
}
答案 0 :(得分:0)
我的主张: 创建一个BaseClass
public class BaseClass: Form
...并为其添加方法:
protected override void OnLoad(EventArgs e)
{
base.OnLoad(e);
foreach (Form frm in Application.OpenForms)
{
frm.WindowState = FormWindowState.Normal;
frm.FormBorderStyle = System.Windows.Forms.FormBorderStyle.None;
frm.Bounds = Screen.PrimaryScreen.Bounds;
}
}
将这个确切的基类添加到每个表单中,例如:
public partial class Form1 : BaseClass