申请退出表格二表格项目 [英] Application Exit Form two Forms Project

查看:68
本文介绍了申请退出表格二表格项目的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的想法是..
我有2种表格.
首先,我将运行Form1.它由一个按钮组成.
当我按下按钮时,Form1将隐藏,Form2将出现.
然后,当我从Form2中按下CancelButton时,我想退出表单应用程序(即Form1和Form2均已关闭.)但是应用程序未退出. Form2关闭并且Form1保留在内存中.请问您有什么建议吗?????????????

My idea is..
I have 2 forms.
Firstly i will run Form1.It consist of a button.
When I press on the button, Form1 will hide and Form2 will appear.
And then when I press the CancelButton from Form2, I wanna exit form application (ie. both Form1 and Form2 are closed.)But yet applicatoin not exit. Form2 closed and Form1 remain on memory. Would u help me any suggestion please??????????????

推荐答案

尝试
Try the Application.Exit[^] method.

An alternative is to hide Form1 when you display Form2, but use ShowDialog rather than the Show method. You can then use Close on Form1 when Form2 closes.

Or you could add an event handler in Form1 for the Form2 instance FormClosed event, and close Form1.


要停止所有线程上所有正在运行的消息循环并关闭应用程序的所有窗口,请使用Application.Exit()功能.我怀疑您正在使用this.Close()函数.让我们在Application.Exit()Close()函数之间进行一些区别.看看
To stops all running message loops on all threads and closes all windows of the application you should use Application.Exit() function. I am suspecting you are using this.Close() function. lets take some difference between Application.Exit() and Close() function.Take a look there-MSDN-[this.close() Vs Application.Exit()][^] for more references


这篇关于申请退出表格二表格项目的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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