当异常不正确时,表单将关闭 [英] Form is closed when exception is not true

查看:99
本文介绍了当异常不正确时,表单将关闭的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Hello Guys,这是一个非常愚蠢的问题我面临的问题是当数据表为空时我想要的应用程序将被关闭,当数据表不为null时,它会显示消息框并返回表单但是当数据时表格不为空,所以表格正在关闭我不知道是什么问题请检查并建议我

谢谢



我尝试过:



 if(dt44 == null)
{
Application.Exit ();
}
else
{
MessageBox.Show(表再次打开登录并打开它们,表打开,MessageBoxButtons.OK,MessageBoxIcon.Error);
返回;
}

解决方案

使用调试器,检查数据表dt44是否为空。例如,有可能包含一个空的数据表或类似的东西。



另一件事是,为什么不在程序启动时检查数据表,在创建之前形成。这样您就可以决定是否创建主表单,而不必担心返回表单。关于主要方法,请看一下这个对话。 c# - Where是表单应用程序中的Main方法? - 堆栈溢出 [ ^ ]


您可以使用:

  if (dt44.Rows.Count <  =  0 


Hello Guys, Here is the one problem very stupid problem am facing that is I want when data table is null so application will be closed and when data table is not null so it shows message box and return the form but when the data table is not null so form is closing I don't know what's the issue please check it and suggest me
Thanks

What I have tried:

if (dt44 ==null)
            {
                Application.Exit();
            }
            else
            {
                MessageBox.Show("Tables Are Open Login Again And punch Them", "Tables Open", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }

解决方案

Using debugger, check that the data table dt44 is null. Chances are that is for example contains an empty data table or similar.

Another thing is that why not check the data table when the program starts, before you have created the form. This way you could decide whether to create the main form or not and you wouldn't have to worry about returning to the form. About main method, have a look at this conversation .c# - Where is the Main method in a forms application? - Stack Overflow[^]


You can use:

if (dt44.Rows.Count <= 0)


这篇关于当异常不正确时,表单将关闭的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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