我怎样才能把一个最小无模式的WinForm到previously编程方式显示的位置? [英] How can I bring a minimized modeless WinForm to its previously displayed position programmatically?
问题描述
要带来一个无模式的Windows窗体时单击事件的previous的位置,我想使用如下所示的code,但它不工作。
请让我知道如果我缺少什么。
公共无效的SetFocus()
{
this.Focus();
this.BringToFront();
如果(this.WindowState == FormWindowState.Minimized)
this.Select();
}
如果窗体最小化,并要使其可见,你需要的恢复的吧。您可以通过设置其<一个href="http://msdn.microsoft.com/en-us/library/system.windows.forms.form.windowstate.aspx"><$c$c>WindowState$c$c>物业以 FormWindowState.Normal
。
例如,改变你的code到这个代替:
公共无效的SetFocus()
{
如果(this.WindowState == FormWindowState.Minimized)
this.WindowState = FormWindowState.Normal;
this.Focus();
this.BringToFront();
}
To bring a modeless Windows Form to its previous position upon a click event, I am trying to use the code shown below, but its not working.
Please let me know if I am missing anything.
public void SetFocus()
{
this.Focus();
this.BringToFront();
if (this.WindowState==FormWindowState.Minimized)
this.Select();
}
If the form is minimized and you want to make it visible, you'll need to restore it. You do this by setting its WindowState
property to FormWindowState.Normal
.
For example, change your code to this instead:
public void SetFocus()
{
if (this.WindowState == FormWindowState.Minimized)
this.WindowState = FormWindowState.Normal;
this.Focus();
this.BringToFront();
}
这篇关于我怎样才能把一个最小无模式的WinForm到previously编程方式显示的位置?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!