实现隐藏窗体而非关闭的方法

当用户点击窗体上的关闭按钮时,如果不想关闭窗体而是隐藏它,可采用下面的方法。

// Use this event handler for the FormClosing event.
private void MyForm_FormClosing(object sender, FormClosingEventArgs e)
{
   this.Hide();
   e.Cancel = true; // this cancels the close event.
}
posted @ 2014-03-19 15:17  马语者  阅读(1512)  评论(0编辑  收藏  举报