如何在儿童表格中调用MDI表单事件 [英] How to Call MDI Form Event in Child Form

查看:74
本文介绍了如何在儿童表格中调用MDI表单事件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何在子窗体中调用MDI窗体事件

How to Call MDI Form Event in Child Form

推荐答案

您不能:事件只能从创建它们的类中调用。并且儿童形式不应该知道MDI父母,除非他们真的,真的必须 - 他们很少这样做。从OOPs POV访问父母是个坏主意。



相反,在Parent订阅的子表单中创建一个事件。在处理程序中,父母可以采取它认为合适的任何行动。

见这里:在两种形式之间传递信息,第2部分:儿童到父母 [ ^ ]
You can't: events can only be invoked from the class that created them. And Child forms should not know about the MDI parent unless they really, really have to - which they rarely do. Accessing Parents is a bad idea from an OOPs POV.

Instead, create an event in the Child form to which the Parent subscribes. In teh handler, teh Parent can take whatever action it deems appropriate.
See here: Transferring information between two forms, Part 2: Child to Parent[^]


这篇关于如何在儿童表格中调用MDI表单事件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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