如何在C#中卸载from [英] How do I unload a from in C#

查看:88
本文介绍了如何在C#中卸载from的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这是我的代码c#



this is my code in c#

private void timer1_Tick(object sender, EventArgs e)
        {
            if (timer1.Interval == 600)
            {

                Splash spl = new Splash();
                spl.Close();
                MDIParent1 frm = new MDIParent1();
                frm.Show();
                
            }
            else
            {
                timer1.Interval = timer1.Interval + 100;
            }
        }





我的尝试:



private void timer1_Tick(object sender,EventArgs e)

{

if(timer1.Interval == 600)

{



Splash spl = new Splash();

spl.Close();

MDIParent1 frm = new MDIParent1();

frm.Show();



}

else

{

timer1.Interval = timer1.Interval + 100;

}

}



What I have tried:

private void timer1_Tick(object sender, EventArgs e)
{
if (timer1.Interval == 600)
{

Splash spl = new Splash();
spl.Close();
MDIParent1 frm = new MDIParent1();
frm.Show();

}
else
{
timer1.Interval = timer1.Interval + 100;
}
}

推荐答案

问题是你没有关闭启动画面的正确实例:

The problem is that you aren't closing the correct instance of the splash screen:
Splash spl = new Splash();
spl.Close();

你创建了一个新的启动画面实例 - 它没有显示 - 并关闭它。

你需要关闭实际的启动画面正在显示。



我要开始的地方是将计时器移动到启动屏幕本身,然后关闭它:

You create a new instance of the splash screen - which isn't ever shown - and close that.
You need to close the actual splash screen that is being displayed.

Where I would start is by moving the timer into the splash screen itself, and closing it there:

private void timer1_Tick(object sender, EventArgs e)
        {
            if (timer1.Interval == 600)
            {
                Close();
            }
            else
            {
                timer1.Interval = timer1.Interval + 100;
            }
        }



然后我会在MDIParent构造函数中显示启动画面,在10秒或之后,启动画面自动关闭。如果将启动屏幕Topmost属性设置为true,则它不能在MDI Parent后面隐藏,并且父项可以在显示启动时继续初始化。


Then I'd display the splash screen in the MDIParent constructor and after the 10 seconds or whatever, the splash screen closes itself. If you set the splash screen Topmost property to true, it can't get "hidden" behind the MDI Parent, and the parent can get on with it's initialization while the splash is displayed.


这篇关于如何在C#中卸载from的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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