Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/290.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 关闭windows窗体,但它仍在任务栏中运行_C# - Fatal编程技术网

C# 关闭windows窗体,但它仍在任务栏中运行

C# 关闭windows窗体,但它仍在任务栏中运行,c#,C#,我正在尝试关闭winform“启动屏幕”并运行另一个窗体 private void timer1_Tick(object sender, EventArgs e) { rectangleShape2.Width += 5; if (rectangleShape2.Width >= 473) { timer1.Stop(); HomeScreen H = new HomeScreen();

我正在尝试关闭winform“启动屏幕”并运行另一个窗体

private void timer1_Tick(object sender, EventArgs e)
    {
        rectangleShape2.Width += 5;
        if (rectangleShape2.Width >= 473)
        {
            timer1.Stop();
            HomeScreen H = new HomeScreen();
            H.ShowDialog();
            //to close current form
            this.Close();
        }
    }
问题在于:启动屏幕窗体仍在任务栏中工作
如何关闭它并在任务栏中隐藏它


谢谢。

希望此解决方案对您有所帮助

void tmr_Tick(object sender, EventArgs e)

 {

     //after 3 sec stop the timer

     tmr.Stop();

     //display mainform

     Mainform mf = new Mainform();

     mf.Show();

     //hide this form

     this.Hide();

 }

Double-click on the FormClosed Event and add this Code:
private void Mainform_FormClosed(object sender, FormClosedEventArgs e)

{

     //exit application when form is closed

     Application.Exit();

} 
试着替换

this.Hide()


它对我有效

使用
H.Show()
而不是
H.ShowDialog()
@AhmedAbdelhameed它不起作用。启动屏幕和新表单关闭,此时必须将“启动屏幕”作为启动表单。看看。如果是这样的话,你可以从这个问题的答案中得到一些帮助。但是,将启动屏幕作为启动窗体不是一个好主意,因此您可能需要稍微调整一下逻辑。启动屏幕是我的启动窗体!因此,它将从第一次开始关闭应用程序
this.Close()