如何隐藏form1的同时Application.Run(Form1中)正在执行? [英] How can I hide form1 while Application.Run(form1) is executing?

查看:193
本文介绍了如何隐藏form1的同时Application.Run(Form1中)正在执行?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述


我有我与运行Form1的 Application.Run


I have a form1 that I run with Application.Run.

我要隐藏这种形式(我需要它隐藏起来,因为我跑一些事情的背景,所以他们必须执行)和一个登录打开另一种形式。

I want to hide this form (I need it hidden because I run some things in the background, so they must execute) and open another form for a log-in.

的方式,我想这是我在Form1构造执行命令 this.Hide(); ,如果登录成功后,显示我Form1上,但它似乎并没有工作。任何想法?

The way I am trying this is by executing in my form1 constructor the command this.Hide(); and if log in is successful, show my form1, but it doesn't seem to work. Any ideas?

推荐答案

只是重写OnVisibleChanged方法,改变在那里形式的知名度,是这样的:

Just override the OnVisibleChanged method and change the visibility of the form in there, something like this:

protected override void OnVisibleChanged(EventArgs e)
{
    base.OnVisibleChanged(e);
    this.Visible = false;
}

这就是它!简单干净。

And that's it! Simple and clean.

这篇关于如何隐藏form1的同时Application.Run(Form1中)正在执行?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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