-3

在我的 c# forms 项目中,我希望每次加载任何表单时都运行此方法。

        foreach (Form frm in Application.OpenForms)
        {
            frm.WindowState = FormWindowState.Normal;
            frm.FormBorderStyle = System.Windows.Forms.FormBorderStyle.None;
            frm.Bounds = Screen.PrimaryScreen.Bounds;
        }
4

1 回答 1

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
于 2017-01-31T14:04:57.113 回答