添加 NotifyIcon,设定你在托盘的图标 把form 的 showintoolbar 设为 false
private void ntIcon_DoubleClick(object sender, System.EventArgs e) { if (this.WindowState == FormWindowState.Minimized) { this.Visible=true; this.WindowState = FormWindowState.Normal; this.Activate(); } else { WindowState=FormWindowState.Minimized; this.Visible=false; } }
private void fm_Main_Resize(object sender, System.EventArgs e) { if (this.WindowState == FormWindowState.Minimized) { this.Visible = false; this.notifyIcon1.Icon = this.Icon; this.notifyIcon1.Text = this.Text; this.notifyIcon1.Visible = true; } }private void notifyIcon1_Click(object sender, System.EventArgs e) { this.Visible = true; this.WindowState = FormWindowState.Normal; this.notifyIcon1.Visible = false;}
private void ntIcon_DoubleClick(object sender, System.EventArgs e) { if (this.WindowState == FormWindowState.Minimized) { this.Visible=true; this.WindowState = FormWindowState.Normal; this.Activate(); } else { WindowState=FormWindowState.Minimized; this.Visible=false; } }
private void fm_Main_Resize(object sender, System.EventArgs e) { if (this.WindowState == FormWindowState.Minimized) { this.Visible = false; this.notifyIcon1.Icon = this.Icon; this.notifyIcon1.Text = this.Text; this.notifyIcon1.Visible = true; } }private void notifyIcon1_Click(object sender, System.EventArgs e) { this.Visible = true; this.WindowState = FormWindowState.Normal; this.notifyIcon1.Visible = false;}
解决方案 »
- c#动态编译?
- c# 文件重命名的时候报错:文件正在被使用?
- 给分100问一个实用的问题?
- 为什么删除的行不能更新到数据库?
- 判断只能输入的是数字或逗号
- IE下 Ajax错误信息 Bad Request(invalid url)
- 如何重绘datagrid的其中一列数据,比如原来是1,要显示为0.001
- C#數據庫鏈接大全(二)
- 如何把若干个TEXTBOX中的内容作为一条记录INSERTI 回数据库
- ?? 弄了个液晶后,WINDOWS自动设置了一种字体给ie,看起来很圆滑,我想知道这个是哪种字体,在哪里设置啊?
- 鼠标单击事件如何区分左右建
- 我时WMI方面的新手,可是说刚刚接触,我需要这方面的书籍
if (this.WindowState == System.Windows.Forms.FormWindowState.Minimized)
this.notifyIcon1.Visible = true;
else
this.notifyIcon1.Visible = false;
{
e.Cancel =true;
this.Hide ();
this.notifyIcon1.Visible =true;
}private void notifyIcon1_DoubleClick(object sender, System.EventArgs e)
{
if(this.Visible ==true) //根据窗口的显示和隐藏设置Trayico对象的显示
{
this.Hide();
this.notifyIcon1 .Visible =true;
}
else
{
this.Show();
this.notifyIcon1.Visible =false;
}
}
应该是showintaskbar 吧