请关闭按钮隐藏而不是关闭而不是、按钮

2023-09-04 10:29:00 作者:此间风雅颂

我怎样才能让一个窗体上的关闭按钮,有效地充当一个隐藏按钮?

How can I make the close button on a form effectively act as a 'Hide' button?

有没有办法中止的FormClosing 事件?

推荐答案

您可以只捕获的FormClosing 事件,并停止默认的动作,然后,而不是关闭窗体只是隐藏:

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();
}
 
精彩推荐
图片推荐