如何在.NET中关闭事件时将表单最小化为Sys托​​盘

0 .net system-tray

如何在.NET中关闭事件时最小化表单到系统托盘

请帮忙.....

jgo*_*ula 6

将NotifyIcon控件添加到窗体和FormClosing的事件处理程序:

private void Form1_FormClosing(Object sender, FormClosingEventArgs e)
{
    if (e.CloseReason == CloseReason.UserClosing)
    {
        e.Cancel = true;
        this.Visible = false;
        this.notifyIcon1.Visible = true;
    }
}
Run Code Online (Sandbox Code Playgroud)