我有一个大师班然后2个孩子班我有一个计时器在Childclass1哪个会给我一些价值我必须将这个值复制到Childclass2并显示只使用大师班 [英] I Have A Master Class Then 2 Child Classes I Have A Timer In Childclass1 Which Will Give Some Value I Have To Copy This Value To Childclass2 And Show By Using Only Masterclass

查看:90
本文介绍了我有一个大师班然后2个孩子班我有一个计时器在Childclass1哪个会给我一些价值我必须将这个值复制到Childclass2并显示只使用大师班的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个Master Class然后是2个子类我在childclass1中有一个计时器会给出一些值

i必须将这个值复制到childclass2

并通过使用显示只有大师班



请给我一个示例代码来达到这个目的。



注意:没有静态变量和没有循环引用

I have a Master Class then 2 child classes i have a timer in childclass1 which will give some value
i have to copy this value to childclass2
and show by using only masterclass

please give me a sample code to attain this.

NOTE: No Static variables and No cyclic References

推荐答案

使用事件:子类1引发一个事件,该事件在MasterClass中处理 - 然后它将信息路由到第二个子类实例。 />


看看这个:在两种表格之间传递信息,第3部分:儿童与儿童 [ ^ ] - 它是面向表单的,但它与普通类的原理和技术完全相同。
Use events: child class1 raises an event, which is handled in the MasterClass - it then routes the info to the second child class instance.

Have a look at this: Transferring information between two forms, Part 3: Child to Child[^] - it's form oriented, but it's exactly the same principle and technique for "normal" classes.

这篇关于我有一个大师班然后2个孩子班我有一个计时器在Childclass1哪个会给我一些价值我必须将这个值复制到Childclass2并显示只使用大师班的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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