如何在c#.net中创建表单卸载事件 [英] how to make form unload event in c#.net

查看:90
本文介绍了如何在c#.net中创建表单卸载事件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

你好朋友

我必须在卸载表单时关闭与数据库的连接,但是找不到该事件。我该怎么做?

因为我已经在表单加载时打开了连接我必须做的关闭...

请帮助!!

hello friends
i have to close connection to database on unload of the form ,but couldn''t found that event . how should i do the same ?
because i have open the connection at form load same thing i have to do for close ...
please help !!

推荐答案

查看 Form.FormClosing事件 [ ^ ]或覆盖Dispose方法并在那里进行。



就个人而言,我会选择FormClosing事件,因为Dispose调用可能不会发生数小时或数周表格关闭后。
Look at the Form.FormClosing event[^] or override the Dispose method and do it there.

Personally, I would go for the FormClosing event because the Dispose call may not happen for hours or weeks after the form has been closed.


Hello Freind

您可以使用

FormClosed或FormClosing活动

我希望能帮到你
Hello Freind
You can use
FormClosed or FormClosing Event
I hope that help you


这篇关于如何在c#.net中创建表单卸载事件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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