之前都是用C#来做Web,没有用C#做过winform,这几天抽空做了一个家庭理财系统,系统还是有一定的可用性的,不过在处理form窗口自带的关闭按钮的时候,不管我是用close()方法,还是用资源回收的方法,那鬼东西死活关不掉,结果是用这个方法关掉的,类似关闭线程,应该还不错。哇哈哈~

1 /// <summary>
2 /// 主窗口自带的关闭按钮
3 /// </summary>
4 /// <param name="sender"></param>
5 /// <param name="e"></param>
6   private void MainForm_FormClosing(object sender, FormClosingEventArgs e)
7 {
8 DialogResult result;
9 result = MessageBox.Show("确定退出吗?", "退出", MessageBoxButtons.OKCancel, MessageBoxIcon.Question);
10 if (result == DialogResult.OK)
11 {
12 Application.ExitThread();
13 }
14 else
15 {
16 e.Cancel = true;
17 }
18 }
这里是添加了form的FormClosing事件,不过之前怎么搞不定。。。囧,估计是跨了的缘故吧,哈哈记录下来。

相关文章:

  • 2022-12-23
  • 2022-12-23
  • 2021-07-11
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-02-08
猜你喜欢
  • 2021-09-27
  • 2022-12-23
  • 2021-10-31
  • 2022-12-23
  • 2022-12-23
  • 2021-06-07
  • 2022-12-23
相关资源
相似解决方案