C#winform中怎么将程序最小化到系统托盘? C#winform中怎么将程序最小化到系统托盘?各位高手教教我! 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 首先需要在窗体中增加一个NotifyIcon控件,并给控件指定图片。/// <summary>/// 显示隐藏窗口/// </summary>/// <param name="showWindow"></param>private void ShowHideWindow(bool showWindow){ if(showWindow == true)//显示 { if(this.ShowInTaskbar==false) { this.ShowInTaskbar = true; this.Visible = true; //this.Show(); } if(this.WindowState == FormWindowState.Minimized) { this.WindowState = FormWindowState.Normal; } this.Activate(); } else//隐藏 { if(this.WindowState == FormWindowState.Minimized) { this.WindowState = FormWindowState.Normal; } if(this.ShowInTaskbar == true) { this.ShowInTaskbar = false; this.Visible = false; //this.Hide(); } }} 在form中添加一个NotifyIcon控件this.notifyIcon1 = new System.Windows.Forms.NotifyIcon(this.components);notifyIcon1.Icon = new Icon("app.ico");//指定一个图标notifyIcon1.Visible = false;notifyIcon1.Click += new System.EventHandler(this.notifyIcon1_Click);this.SizeChanged += new System.EventHandler(this.Form1_SizeChanged);private void Form1_SizeChanged(object sender, EventArgs e){ if (this.WindowState==FormWindowState.Minimized)//最小化 { his.ShowInTaskbar = false; this.notifyIcon1.Visible=true; }}private void notifyIcon1_Click(object Sender, EventArgs e)//单击系统栏图标激活窗体{ if (this.WindowState == FormWindowState.Minimized) this.WindowState = FormWindowState.Normal; this.Activate(); this.notifyIcon1.Visible = false; this.ShowInTaskbar = true;} Drawing类下Image和contral类下Image怎么转换 怎么获取文件大小呢? c# 向数据库插入数据的迷惑 100分求救:sql2000存储过程高手请进,帖子引用功能中多层引用问题 datatable对象 相减 请教一个小小的问题 怎么根据点击的一个datagrid行的位置确定另外一个datagrid的位置 求大神,解答关于User32.dll的问题 C#连接sql,登陆失败 所有分放送,在线等,大哥们帮我看看这个错误 求一关于时间数据转换的sql语句 怎么就搞不定呢?急呀!
/// 显示隐藏窗口
/// </summary>
/// <param name="showWindow"></param>
private void ShowHideWindow(bool showWindow)
{
if(showWindow == true)//显示
{
if(this.ShowInTaskbar==false)
{
this.ShowInTaskbar = true;
this.Visible = true;
//this.Show();
}
if(this.WindowState == FormWindowState.Minimized)
{
this.WindowState = FormWindowState.Normal;
}
this.Activate();
}
else//隐藏
{
if(this.WindowState == FormWindowState.Minimized)
{
this.WindowState = FormWindowState.Normal;
}
if(this.ShowInTaskbar == true)
{
this.ShowInTaskbar = false;
this.Visible = false;
//this.Hide();
}
}
}
this.notifyIcon1 = new System.Windows.Forms.NotifyIcon(this.components);
notifyIcon1.Icon = new Icon("app.ico");//指定一个图标
notifyIcon1.Visible = false;
notifyIcon1.Click += new System.EventHandler(this.notifyIcon1_Click);
this.SizeChanged += new System.EventHandler(this.Form1_SizeChanged);private void Form1_SizeChanged(object sender, EventArgs e)
{
if (this.WindowState==FormWindowState.Minimized)//最小化
{
his.ShowInTaskbar = false;
this.notifyIcon1.Visible=true;
}
}private void notifyIcon1_Click(object Sender, EventArgs e)
//单击系统栏图标激活窗体
{
if (this.WindowState == FormWindowState.Minimized)
this.WindowState = FormWindowState.Normal;
this.Activate();
this.notifyIcon1.Visible = false;
this.ShowInTaskbar = true;
}