private void Alerts_FormClosing(object sender, FormClosingEventArgs e)
{
if (e.CloseReason == CloseReason.UserClosing)
{
e.Cancel = true;
this.WindowState = FormWindowState.Minimized;
}
}
Monday, May 17, 2010
How to minimize window from closing C# windows application
To minimize the window when user closes the form, use the code below.
Labels:
C#,
Windows Application
Thursday, May 13, 2010
How to prevent form closing in C# windows application
In some cases you need to prevent closing the application/form when user clicks windows close button.
Use the following code snippet to do so
Use the following code snippet to do so
private void Form1_FormClosing(object sender, FormClosingEventArgs e)
{
if (e.CloseReason == CloseReason.UserClosing)
{
e.Cancel = true;
}
}
Labels:
C#,
Form Closing
Subscribe to:
Posts (Atom)