可能重复:
从最小化恢复 WindowState
我有通常隐藏在托盘栏中的窗口。
然后我想显示它是否隐藏,并带到前面。
如果它已经打开,我只想把它带到前面。
如果它被最小化到任务栏,那么我想扩展它并放在前面。
现在我的 show 方法中有这个:
this.Show();
this.Activate();
this.ShowInTaskbar = true;
this.TopMost = true;
this.Focus();
但如果它被最小化,它不会扩大。
如何解决这个问题?
可能重复:
从最小化恢复 WindowState
我有通常隐藏在托盘栏中的窗口。
然后我想显示它是否隐藏,并带到前面。
如果它已经打开,我只想把它带到前面。
如果它被最小化到任务栏,那么我想扩展它并放在前面。
现在我的 show 方法中有这个:
this.Show();
this.Activate();
this.ShowInTaskbar = true;
this.TopMost = true;
this.Focus();
但如果它被最小化,它不会扩大。
如何解决这个问题?
尝试添加this.WindowState = FormWindowState.Maximized
有关 FormWindowState 枚举的完整详细信息,请参见此处
if (this.WindowState == FormWindowState.Minimized)
this.WindowState = FormWindowState.Normal;
this.Show();
this.Activate();
this.ShowInTaskbar = true;
this.TopMost = true;
this.Focus();
如果它被最小化,您将不得不使用WindowState属性来恢复窗口。
this.WindowState = FormWindowState.Maximized; // To maximize
this.WindowState = FormWindowState.Normal; // To restore