0

我需要在几秒钟后隐藏当前表单,然后显示任何表单

我正在编写此代码,但它不起作用。

namespace tempprj
{
    public partial class ProfileFrm : Telerik.WinControls.UI.RadForm
    {
       public ProfileFrm()
       {
           InitializeComponent();
       }

       private void ProfileFrm_Load(object sender, EventArgs e)
       {
            Frm2 child = new Frm2();
            Thread.Sleep(3000);
            this.Hide();
            child.ShowDialog();
       }
   }

}

4

2 回答 2

2
Thread.Sleep(3000);

将阻止您的项目在 3 秒内执行任何操作(不包括其他线程)并冻结 UI。我建议使用标准的 .NET 计时器。

http://msdn.microsoft.com/en-us/library/system.windows.forms.timer.aspx

于 2012-08-02T20:12:27.893 回答
0

这是我的问题的解决方案:

    private void ProfileFrm_Load(object sender, EventArgs e)
    {
        timer1.Tick += new EventHandler(timer1_Tick);

        timer1.Enabled = true;
        timer1.Interval = 4000;
        timer1.Start();

    }

    private void timer1_Tick(object sender, EventArgs e)
    {
        timer1.Stop();

        this.Hide();
        Frm2 f = new Frm2();

        f.ShowDialog();
    }
于 2012-08-02T21:40:33.197 回答