0

我在选项菜单中有按钮,我希望能够一次更改每个表单的样式。目前它只适用于选项菜单本身,因为我使用了“this”。

   private void Fullscreen_toggle_Click(object sender, EventArgs e)
    {
        this.WindowState = FormWindowState.Normal;
        this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.None;
        this.Bounds = Screen.PrimaryScreen.Bounds;
    }

    private void Windowed_toggle_Click(object sender, EventArgs e)
    {
        this.WindowState = FormWindowState.Maximized;
        this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.Sizable;
    }

有没有办法让它在全球范围内应用?

4

1 回答 1

0

像这样遍历Application.OpenForms()集合:

    private void Fullscreen_toggle_Click(object sender, EventArgs e)
    {
        foreach (Form frm in Application.OpenForms)
        {
            frm.WindowState = FormWindowState.Normal;
            frm.FormBorderStyle = System.Windows.Forms.FormBorderStyle.None;
            frm.Bounds = Screen.PrimaryScreen.Bounds;
        }     
    }
于 2017-01-08T15:22:24.143 回答