如何在进度条完成后加载新表单?新形式没有显示帮助我。 THANX [英] how to load a new form after progress bar complete? new form is not showing help me with this. ThanX

查看:56
本文介绍了如何在进度条完成后加载新表单?新形式没有显示帮助我。 THANX的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

private void timer1_Tick(object sender, EventArgs e)
       {
           progressBar1.Increment(1);
           if (progressBar1.Value == 5000)
           {
              // timer1.Stop();
               this.Close();
               Main_form mnfrm = new Main_form();
               mnfrm.ShowDialog();
               timer1.Enabled = false;
           }
       }

推荐答案

很难知道从哪里开始。



如果您的Main_form没有显示,可能是因为您尝试显示它的表单是您的启动表单 - 当您关闭时,您的应用程序终止 - 所以你永远不会看到新的表单。



我会改为隐藏表单,然后在Main_form实例从ShowDialog返回后关闭它。但是我也会禁用条件顶部的计时器。



如果您要做的是显示某种形式的闪屏,然后我不会这样做 - 我会看看这个: C#中一个非常好的启动画面 [ ^ ]
It''s difficult to know where to start really.

If your Main_form isn''t showing, it''s probably because the form you are trying to show it from is your startup form - and when you close that your application terminates - so you never get to see the new form.

I would instead Hide the form and then Close it after the Main_form instance returns from ShowDialog. But I''d disable the timer at the top of the conditional, as well.

If what you are trying to do is show a splash screen of some form, then I wouldn''t do it this way - I would have a look at this instead: A Pretty Good Splash Screen in C#[^]


这篇关于如何在进度条完成后加载新表单?新形式没有显示帮助我。 THANX的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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