我怎样才能把一个最小无模式的WinForm到previously编程方式显示的位置? [英] How can I bring a minimized modeless WinForm to its previously displayed position programmatically?

查看:112
本文介绍了我怎样才能把一个最小无模式的WinForm到previously编程方式显示的位置?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

要带来一个无模式的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物业以 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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆