表格拒绝关闭 [英] Form is refusing to close

查看:92
本文介绍了表格拒绝关闭的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

您好我有一个winforms应用程序拒绝关闭启动表单。



          

  private static void Main()

        {

            Application.EnableVisualStyles();

            Application.SetCompatibleTextRenderingDefault(false);




            var main_form = new frmSplash();

            main_form.Show();

            Application.Run();

        }



在我的按钮中,我正在使用this.close并且根本没有关闭表格,我可以解决这个问题。



问候


解决方案

嗨David,


尝试使用" Application.Exit();"


< pre class ="prettyprint x-hidden-focus"> private void button1_Click(object sender,EventArgs e)
{
//this.Close();
Application.Exit();
}

或更改Main中的代码:

 [STAThread] 
static void Main()
{
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);
Application.Run(new frmSplash());
}

问候,


Frankie


Hi I have a winforms app that is refusing to close the startup form.

          

 private static void Main()
        {
            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);


            var main_form = new frmSplash();
            main_form.Show();
            Application.Run();
        }

In my button I am using this.close and its not closing the form at all any ideas how I can cure this.

Regards

解决方案

Hi David,

Try using "Application.Exit();" instead:

    private void button1_Click(object sender, EventArgs e)
    {
        //this.Close();
        Application.Exit();
    }

Or change the code in Main:

    [STAThread]
    static void Main()
    {
        Application.EnableVisualStyles();
        Application.SetCompatibleTextRenderingDefault(false);
        Application.Run(new frmSplash());
    }

Regards,

Frankie


这篇关于表格拒绝关闭的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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