Stephen Wrighton
Stephen Wrighton

Reputation: 37850

Is there a way to programmatically minimize a window

What I'm doing is I have a full-screen form, with no title bar, and consequently lacks the minimize/maximize/close buttons found in the upper-right hand corner. I'm wanting to replace that functionality with a keyboard short-cut and a context menu item, but I can't seem to find an event to trigger to minimize the form.

Upvotes: 79

Views: 139809

Answers (10)

Abdul Moiz
Abdul Moiz

Reputation: 33

this.WindowState = FormWindowState.Minimized;

Upvotes: 2

Thailor Souza
Thailor Souza

Reputation: 1

-- c#.net

NORMALIZE this.WindowState = FormWindowState.Normal;

this.WindowState = FormWindowState.Minimized;

Upvotes: 0

GoroundoVipa
GoroundoVipa

Reputation: 259

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

Me.Hide()

End Sub

Upvotes: -4

Tech Initiator
Tech Initiator

Reputation: 1

this.MdiParent.WindowState = FormWindowState.Minimized;

Upvotes: -1

JP Richardson
JP Richardson

Reputation: 39425

FormName.WindowState = FormWindowState.Minimized;

Upvotes: 37

chetan
chetan

Reputation:

in c#.net

this.WindowState = FormWindowState.Minimized

Upvotes: 26

profnotime
profnotime

Reputation: 321

There's no point minimizing an already minimized form. So here we go:

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

Upvotes: 3

John Dages
John Dages

Reputation:

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

Upvotes: 125

Stephen Deken
Stephen Deken

Reputation:

Form myForm;
myForm.WindowState = FormWindowState.Minimized;

Upvotes: 8

Craig Eddy
Craig Eddy

Reputation: 969

<form>.WindowState = FormWindowState.Minimized;

Upvotes: 11

Related Questions