本文介绍了如何关闭Form1并打开窗体2的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
在Form1上,当进度条完成,然后在timer_tick事件'else部分下面的代码是我写的:
In Form1 when progressbar is completed then in timer_tick events' else part the following code is written by me:
frmLogin login = new frmLogin();
login.Show();
timer1.Enabled = false;
this.Hide();
因此,任何解决方案,以关闭 Form1中
代替隐藏 Form1中
?
推荐答案
您有一些所谓的 的ApplicationContext
为
You have something called the ApplicationContext
for that.
使用这样的:
ApplicationContext applicationContext = new ApplicationContext();
FormX formX = new FormX(applicationContext);
applicationContext.MainForm = formX;
Application.Run(applicationContext);
在结束 Form1中
,拱手的MainForm
FormY formY = new FormY(applicationContext);
applicationContext.MainForm = formY;
另一种方法是使静态的ApplicationContext
。这不会要求各地传递给它。
Another option is to make a static ApplicationContext
. That wouldn't require passing it around.
这篇关于如何关闭Form1并打开窗体2的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!