源代码如下:
请在工具栏把notifyIcon控件拖入窗体再使用:
//隐藏窗体 private bool windowCreate = true; private void toolStripMenuItem1_Click(object sender, EventArgs e) //这是菜单选项的一个item点击事件 { if (windowCreate) { base.Visible = false; windowCreate = false; } this.Hide(); base.OnActivated(e); } //显示回窗体(notifyIcon控件双击事件,注:请选择一个ico图标,这样隐藏后在右下角显示有相关图标) private void notifyIcon1_MouseDoubleClick(object sender, MouseEventArgs e) { if (this.Visible == true) { this.Hide(); this.ShowInTaskbar = false; } else { this.Visible = true; this.ShowInTaskbar = true; this.WindowState = FormWindowState.Normal; //this.Show(); this.BringToFront(); windowCreate = true; } } 文章来自学IT网:http://www.xueit.com/html/2008-05/117_125_00.html