控制盒取消按钮出现问题 [英] problem with control box cancel button

查看:49
本文介绍了控制盒取消按钮出现问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有登录表单和主表单.
登录后,我打开了控制框的取消按钮.
单击主窗体"控制框的取消"按钮时,仅关闭主窗体而不关闭整个应用程序.
如何单击控制"框主窗体的取消"按钮关闭整个应用程序.

I have login form and Main form.
After Login i get opened main form on that there is cancel button of control box.
When click Cancel Button of Control box of Main form it close only Main form not the whole application.
How to close Whole application on Clicking Cancel Button of Main form of Control box.

推荐答案



您可以使用以下方式关闭应用程序.

Hi,

You can close the application using the following way.

private void frmMainMDI_FormClosing(Object sender, FormClosingEventArgs e)
       {
          Application.Exit();

       }


这取决于您的操作方式.
如果要通过Main方法打开登录表单,并在成功登录后隐藏登录表单并显示主表单,则取决于您如何显示它:

如果您使用ShowDialog,则只需在ShowDialog调用之后立即在登录表单中添加一个Close.
如果使用的是Show,则将处理程序添加到主窗体FormClosed事件中,然后从此处调用Close.

如果您正在做其他事情,那么我们需要知道什么,因为我们看不到您的屏幕,无法访问您的HDD或无法读懂您的想法.我们只能与您所说的一起工作! :laugh:
It depends on how you are doing this.
If you are opening the login form from the Main method, and on sucessfull login you are hiding the login form and showing the main form, then it depends on how you are showing it:

If you use ShowDialog, then just add a Close to the login form immediately after the ShowDialog call.
If you are using Show, then add a handler to the main form FormClosed event and call Close from there.

If you are doing something else, then we need to know what, as we can''t see your screen, access your HDD, or read your mind. We can only work with what you tell us! :laugh:


这篇关于控制盒取消按钮出现问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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