Make close button hide instead of closing [duplicate]
How can I make the close button on a form effectively act as a 'Hide' button?
Is there a way to abort the FormClosing event?
You could just capture the FormClosing event and stop the default action, then instead of closing the form just hide it:
private void Form1_FormClosing(object sender, FormClosingEventArgs e)
{
e.Cancel = true;
this.Hide();
}
It should be pretty straight forward:
To cancel the closure of a form, set the
Cancelproperty of theFormClosingEventArgspassed to your event handler totrue.
Concerning part two of the question with hiding the window, hide to taskbar or hide to notification area?
加载中,请稍侯......
精彩评论