一種方法是可以在窗體的屬性面板將窗體的 ControlBox屬性設置為false,或者在窗體的構造函數中這樣寫:
{
e.Cancel = true;
}
// 重寫OnClosing使點擊關閉按鍵時窗體能夠縮進托盤
protected override void OnClosing(CancelEventArgs e)
{
this.ShowInTaskbar = false;
this.WindowState = FormWindowState.Minimized;
e.Cancel = true;
}
新聞熱點
疑難解答