奇怪的问题:关闭MDI Parent重定向到MDI Child [英] Weird Problem: Closing MDI Parent re-directed to MDI Child

查看:100
本文介绍了奇怪的问题:关闭MDI Parent重定向到MDI Child的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

出于某种原因,当我点击X关闭我的MDI父表单时,动作

似乎被重定向到其中一个MDI子表单和父表单

仍然开放。然后我无法关闭申请。


应该发生什么,主要的MDI表格应该关闭,带孩子

表格。有代码循环遍历子窗体,删除每个窗口上的

控件,然后关闭窗体,但是此代码应该只有当用户点击时才执行
一个特定的菜单选项。


实际发生的是当我点击X关闭主窗体时,

第一个子窗体有其所有控件删除,没有别的

发生。


我意识到我没有给予太多的继续,但我只是想知道是否有人

有任何想法/建议可能导致这种情况。


TIA


Charles

For some reason, when I click the X to close my MDI parent form, the action
appears to be re-directed to one of the MDI child forms, and the parent
remains open. I am then unable to close the application.

What should happen, is that the main MDI form should close, taking the child
forms with it. There is code to loop through the child forms, remove the
controls on each of them, and then close the form, but this code should
execute only when the user clicks a specific menu option.

What actually happens is when I click the X to close the main form, the
first of the child forms has all its controls removed, and nothing else
happens.

I realise that I haven''t given much to go on, but I just wondered if anyone
had any thoughts/suggestions of what could cause this.

TIA

Charles

推荐答案




抱歉,我无法重现这种行为。是否有可能

你有表格关闭事件的代码阻止应用程序关闭

正确吗?




-----------------


" Charles Law" < BL *** @ nowhere.com>在消息中写道

新闻:哦************** @ TK2MSFTNGP09.phx.gbl:
Hi,

Sorry I haven''t been able to reproduce that behavior. Is it possible
you have code in forms closing event preventing the app from closing
properly?

Ken
-----------------

"Charles Law" <bl***@nowhere.com> wrote in message
news:Oh**************@TK2MSFTNGP09.phx.gbl:
出于某种原因,当我点击X关闭我的MDI父表单,
动作似乎被重定向到其中一个MDI子表单,而父表单
保持打开状态。然后我无法关闭应用程序。

应该发生什么,主要的MDI表单应该关闭,带上
子表单。有代码循环遍历子窗体,删除每个窗体上的控件,然后关闭窗体,但此代码应该仅在用户单击特定菜单选项时执行。

实际发生的是当我点击X关闭主表单时,
第一个子表单的所有控件都被删除了,没有其他任何事情发生。

我意识到我还没有给予太多帮助,但我只是想知道是否有人对任何可能导致这种情况的想法/建议。

TIA

Charles
For some reason, when I click the X to close my MDI parent form, the
action
appears to be re-directed to one of the MDI child forms, and the parent
remains open. I am then unable to close the application.

What should happen, is that the main MDI form should close, taking the
child
forms with it. There is code to loop through the child forms, remove the

controls on each of them, and then close the form, but this code should
execute only when the user clicks a specific menu option.

What actually happens is when I click the X to close the main form, the
first of the child forms has all its controls removed, and nothing else
happens.

I realise that I haven''t given much to go on, but I just wondered if
anyone
had any thoughts/suggestions of what could cause this.

TIA

Charles




-

外发邮件已通过无病毒验证。

由AVG Anti-Virus检查( http://www.grisoft.com)

版本:7.0.230 /病毒数据库:263.1.2 - 发布日期:2004年6月7日



--
Outgoing mail is certified Virus Free.
Checked by AVG Anti-Virus (http://www.grisoft.com).
Version: 7.0.230 / Virus Database: 263.1.2 - Release Date: 6/7/2004


Hi Ken


导致此效果的确切程序是


S.馅饼主应用

打开MDI儿童表格

关闭MDI儿童表格

打开MDI儿童表格

点击X进入关闭主应用程序


最后一步,在这种情况下,现在导致当前打开的MDI子项

表单清除其控件而不是其他任何内容。如果我在第一次打开之后点击X / b
那么一切都会好的。


我在主MDI父表单中有一个事件处理程序, ''处理

MyBase.Closed'',但是在执行上述步骤之后永远不会调用它(如果我在第一次打开后单击X,则调用
)。


可能会发生什么?


Charles

Ken Tucker [MVP]" < VB *** @ bellsouth.net>在消息中写道

新闻:eV ************** @ TK2MSFTNGP11.phx.gbl ...
Hi Ken

The exact procedure that causes this effect is

Start main app
Open MDI child form
Close MDI child form
Open MDI child form
Click X to close main app

The last step, in this scenario, now causes the currently open MDI child
form to clear its controls and nothing else. If I were to click the X after
the first open then all would be well.

I have an event handler in the main MDI parent form, with ''Handles
MyBase.Closed'', but this is never called after following the steps above (it
is called if I click the X after the first open).

What could be going on?

Charles
"Ken Tucker [MVP]" <vb***@bellsouth.net> wrote in message
news:eV**************@TK2MSFTNGP11.phx.gbl...

抱歉,我无法再现这种行为。是否有可能
你在表格关闭事件中有代码阻止应用程序正常关闭


------------ -----

查尔斯劳 < BL *** @ nowhere.com>在消息中写道
新闻:哦************** @ TK2MSFTNGP09.phx.gbl:
Hi,

Sorry I haven''t been able to reproduce that behavior. Is it possible
you have code in forms closing event preventing the app from closing
properly?

Ken
-----------------

"Charles Law" <bl***@nowhere.com> wrote in message
news:Oh**************@TK2MSFTNGP09.phx.gbl:
出于某种原因,当我点击X关闭时我的MDI父表单,
动作
似乎被重定向到其中一个MDI子表单,而父表单
保持打开状态。然后我无法关闭应用程序。

应该发生什么,主要的MDI表单应该关闭,带上
子表单。有代码循环遍历子窗体,删除每个窗体上的控件,然后关闭窗体,但此代码应该仅在用户单击特定菜单选项时执行。

实际发生的是当我点击X关闭主表单时,
第一个子表单的所有控件都被删除了,没有其他任何事情发生。

我意识到我还没有给予太多帮助,但我只是想知道是否有人对任何可能导致这种情况的想法/建议。

TIA

Charles
For some reason, when I click the X to close my MDI parent form, the
action
appears to be re-directed to one of the MDI child forms, and the parent
remains open. I am then unable to close the application.

What should happen, is that the main MDI form should close, taking the
child
forms with it. There is code to loop through the child forms, remove the

controls on each of them, and then close the form, but this code should
execute only when the user clicks a specific menu option.

What actually happens is when I click the X to close the main form, the
first of the child forms has all its controls removed, and nothing else
happens.

I realise that I haven''t given much to go on, but I just wondered if
anyone
had any thoughts/suggestions of what could cause this.

TIA

Charles



-
发送邮件经过无病毒认证。
由AVG Anti-Virus检查( http://www.grisoft.com)
版本:7.0。 230 /病毒数据库:263.1.2 - 发布日期:2004年6月7日



--
Outgoing mail is certified Virus Free.
Checked by AVG Anti-Virus (http://www.grisoft.com).
Version: 7.0.230 / Virus Database: 263.1.2 - Release Date: 6/7/2004



Charles,
出于某种原因,当我单击X关闭我的MDI时父表单,
操作似乎被重定向到其中一个MDI子表单,
我希望当你关闭MDI父级时它将被重定向到
你所有的MDI儿童表格!由于MDI的父母不能关闭,直到所有的孩子们都关闭了。


换句话说。 MDIParent.Close自动导致MDIChild.Close!

且父级
保持打开状态。然后,我无法关闭该应用程序。
您是否取消了第一个MDI Child's Form.Closing事件?

应该发生什么,主MDI表单应该关闭,带上
子表单。
这是正常的.NET行为,除非你有一个事件,例如Closing,

取消操作。

有代码循环遍历子表单,删除每个控件上的
控件,然后关闭表单,但此代码应仅在用户单击特定菜单选项时执行。
Form.Closing& MDI子表单发生Form.Closed事件,无论是通过代码显式关闭它们还是通过MDI父级隐式关闭

关闭。

什么实际发生的是当我点击X来关闭主窗体时,
第一个子窗体的所有控件都被删除了,没有别的东西发生了。
你删除了所有控件的哪个事件?

你正在处理Form.Closing& Form.Close事件或你是否覆盖了

Form.OnClosing& Form.OnClosed方法。如果你覆盖了OnClosing,那么你还记得调用基本方法吗?


希望这有帮助

Jay


" Charles Law" < BL *** @ nowhere.com>在消息中写道

新闻:哦************** @ TK2MSFTNGP09.phx.gbl ...出于某种原因,当我点击X来关闭我的MDI父表单,
操作似乎被重定向到其中一个MDI子表单,并且父表单
保持打开状态。然后我无法关闭应用程序。

应该发生什么,主要的MDI表单应该关闭,带上
子表单。有代码循环遍历子窗体,删除每个窗体上的
控件,然后关闭窗体,但此代码应该仅在用户单击特定菜单选项时才执行。

实际发生的是当我点击X关闭主窗体时,
第一个子窗体的所有控件都被删除了,没有别的东西发生。

我意识到我没有太多可以继续下去,但我只是想知道是否b $ b b任何人都有任何想法/建议可能导致这种情况。

TIA
Charles
For some reason, when I click the X to close my MDI parent form, the action appears to be re-directed to one of the MDI child forms, I would expect when you close the MDI parent that it will be re-directed to
all of your MDI child forms! As the MDI parent cannot close until all the
MDI child''s are closed.

In other words. MDIParent.Close automatically causes MDIChild.Close!
and the parent
remains open. I am then unable to close the application. Are you canceling the first MDI Child''s Form.Closing event?
What should happen, is that the main MDI form should close, taking the child forms with it. This is normal .NET behavior, unless you have an event, such as Closing,
canceling the operation.
There is code to loop through the child forms, remove the
controls on each of them, and then close the form, but this code should
execute only when the user clicks a specific menu option. The Form.Closing & Form.Closed event occurs for MDI child forms whether they
are closed explicitly via code or implicitly via the MDI parent being
closed.
What actually happens is when I click the X to close the main form, the
first of the child forms has all its controls removed, and nothing else
happens. Which event are you removing all the controls in?
Are you handling the Form.Closing & Form.Closed events or did you override
the Form.OnClosing & Form.OnClosed methods. If you overrode OnClosing, did
you remember to call the base methods?

Hope this helps
Jay

"Charles Law" <bl***@nowhere.com> wrote in message
news:Oh**************@TK2MSFTNGP09.phx.gbl... For some reason, when I click the X to close my MDI parent form, the action appears to be re-directed to one of the MDI child forms, and the parent
remains open. I am then unable to close the application.

What should happen, is that the main MDI form should close, taking the child forms with it. There is code to loop through the child forms, remove the
controls on each of them, and then close the form, but this code should
execute only when the user clicks a specific menu option.

What actually happens is when I click the X to close the main form, the
first of the child forms has all its controls removed, and nothing else
happens.

I realise that I haven''t given much to go on, but I just wondered if anyone had any thoughts/suggestions of what could cause this.

TIA

Charles



这篇关于奇怪的问题:关闭MDI Parent重定向到MDI Child的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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