亲子结帐表格! [英] Child Closing Parent Form!

查看:51
本文介绍了亲子结帐表格!的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正面临一项任务.我已经尝试了很多,但都没有成功.
是否可以从子表单中关闭父表单.

你们能指导我还是给我推荐一些有用的有用链接

解决方案

首先要了解的是:没有功能性关系表单之间的父/子.请查看我过去的答案:父级子窗体关系 [ Windows窗体应用程序 [^ ].

—SA


您可以通过application.exit();


关闭整个应用程序

i m facing a task. i hve tried a lot but of no great success.
is it possible to close parent form from child form.

Can you guys guide me or refer me some USEFUL link which is really useful

解决方案

First thing to understand is: there is not functional relationship parent/child between forms. Please see my past answer: Parent Child Form Relationship[^]. Even though a form is a Control with this relationship, it is made defunct for forms.

Now, the main form is a special one: it is defined by the instance passed to Application.Run. If you close a main form, the whole application (but not the application process) will exit.

Your request is a sing of a flaw in the whole application design. However, there are some cases where the effect you want might be needed.

So, there are at least two approaches.

First, most simple and reasonable is this one: never close the main form but make it hidden instead. This is quite simple.

Another approach is running the singleton Application twice or more than two times: first with one instance of the form, another time with another one, etc. Look at your method Main and modify it according to your logic.

For example, please see a code sample I provided in response to a similar question: Windows Form application[^].

—SA


you can close whole application by application.exit();


这篇关于亲子结帐表格!的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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