有没有办法以编程方式最小化窗口

时间:2008-09-16 04:19:29

标签: c# .net vb.net winforms

我正在做的是我有一个全屏幕形式,没有标题栏,因此缺少右上角的最小化/最大化/关闭按钮。我想用键盘快捷键和上下文菜单项替换该功能,但我似乎找不到触发器来最小化表单的事件。

10 个答案:

答案 0 :(得分:93)

private void Form1_KeyPress(object sender, KeyPressEventArgs e)
{
     if(e.KeyChar == 'm')
         this.WindowState = FormWindowState.Minimized;
}

答案 1 :(得分:31)

FormName.WindowState = FormWindowState.Minimized;

答案 2 :(得分:18)

在c#.net

this.WindowState = FormWindowState.Minimized

答案 3 :(得分:10)

<form>.WindowState = FormWindowState.Minimized;

答案 4 :(得分:7)

Form myForm;
myForm.WindowState = FormWindowState.Minimized;

答案 5 :(得分:2)

最小化已经最小化的形式是没有意义的。所以我们走了:

if (form_Name.WindowState != FormWindowState.Minimized) form_Name.WindowState = FormWindowState.Minimized;

答案 6 :(得分:0)

-c#.net

规范     this.WindowState = FormWindowState.Normal;

this.WindowState = FormWindowState.Minimized;

答案 7 :(得分:0)

this.WindowState = FormWindowState.Minimized;

答案 8 :(得分:-1)

this.MdiParent.WindowState = FormWindowState.Minimized;

答案 9 :(得分:-4)

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click

Me.Hide()

End Sub