从子窗体访问MDIForm [英] Accessing MDIForm from Child Form

查看:90
本文介绍了从子窗体访问MDIForm的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



我想从子窗体中更改我的应用程序的MDI窗体上的某些控件.

我已经能够列出以下两种方法.

1.将子窗体的MDIPArent属性转换为MDIForm Type
2.声明一个事件并在子窗体中引发它.

问题
-还有其他更好的方法可以实现我的目标吗?
-以上两种方法中的哪一种是首选,为什么?

在此先感谢一吨:)

问候

Hi

I want to change certain controls on the MDI form of my application from within my child form.

I have been able to shortlist the following two methods.

1. Casting the MDIPArent property of the child form into the MDIForm Type
2. Declaring an event and raising it within the child form.

Questions
- Is there any other better method of achieving my objective?
- Which of the above two methods are preferred, and why?

Thanks a ton in advance :)

Regards

推荐答案

您还可以设置一个全局静态类,该类包含一个事件,该事件在属性更改时触发,并以所需的形式处理该事件.
You could also set up a global static class that contains an event that fires when a property is changedand handle that event in the desired form.


IMO,如果您希望基于子项中的某些内容进行父项更改,则应在子项中引发一个事件并在该事件中传递更改的信息.
IMO, if you want to have the parent change based on something in the child, you should raise an event in the child and pass the changed information in that event.


这篇关于从子窗体访问MDIForm的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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