如何使用许多this.hide()时关闭表单 [英] how to close a form when used many this.hide()
问题描述
我在项目中使用了很多this.hide,所以问题是我的项目确实通过单击工具栏上的X按钮退出了.(在最小化窗口按钮旁边)
所以我想退出该应用程序.但这并没有发生.每时每刻我都必须停止调试.有没有办法做到这一点.通过单击退出按钮.
我不想使用带有application.exit()
的新按钮
我想使用Windows默认框架关闭右上角的X按钮.
i have used many this.hide in my project so the problem is my project doesent exit by clicking the X button from the tool bar.(by the side of minimize window button)
so i want to exit the application. But it is not happening... evry time i have to stop debugging. Can there is method to do so. That by clicking on the exit button.
I dont want to use a new button which will have application.exit()
i want to use windows default frame closing X button on the top right corner.
推荐答案
您可以在Form上使用FormClosing事件,然后使用application.exit() ...
例如:
you can use the FormClosing event on the Form and then use application.exit()...
example:
private void Form1_FormClosing(object sender, FormClosingEventArgs e)
{
Application.Exit();
}
您还可以使用
this.close()
关闭Windows窗体.
to close your windows form.
如果您在窗体中打开了sql连接,请在隐藏该窗体之前尝试将其关闭(con.Close()).我不知道这是否是问题,但您可以尝试...
If you opened a sql connection in a form try to close it (con.Close()) before you hide that form. I don''t know if this is the problem but you can try...
这篇关于如何使用许多this.hide()时关闭表单的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!