C#怎样做到窗体时最小化到状态栏,双击运行时又能正常显示窗体

2024-12-18 19:25:51
推荐回答(2个)
回答1:

首先在窗体中添加一个 notifyIcon1控件
//添加事件《实现最小化之后任务栏显示图标》
private void Form1_StyleChanged(object sender, EventArgs e)
{
if (this.WindowState == FormWindowState.Minimized)
{
this.notifyIcon1.Visible = true;
this.Visible = false;
}
}

//双击图标之后显示窗体
private void notifyIcon1_MouseDoubleClick(object sender, MouseEventArgs e)
{
this.Visible = true;
this.WindowState = FormWindowState.Normal;
this.notifyIcon1.Visible = false;
}

回答2:

在窗体的对应时间里面编写函数,动态改变窗体的状态属性。