WinForm实现最小化右下角

首先,要在窗体里面加入这么两个控件,左边的是托盘控件,右边的是菜单控件。

然后设置窗体的FormClosing事件:

if (e.CloseReason == CloseReason.UserClosing) 
            {
                e.Cancel = true;
                this.WindowState = FormWindowState.Minimized;
                this.Hide();
                return;
            }

然后再设置notifyIcon1的DoubleClick事件:

private void notifyIcon1_DoubleClick(object sender, EventArgs e)
        {
            this.Show();
            this.WindowState = FormWindowState.Normal;
        }

设置notifyIcon1控件的ContextMenuStrip属性为contextMenuStrip1,然后给contextMenuStrip1增加一个“退出”按钮。

编辑“退出”按钮的Click事件:

private void toolStripMenuItem1_Click(object sender, EventArgs e)
{
    Application.Exit();
}
原文地址:https://www.cnblogs.com/wpcnblog/p/5147245.html