重新使用来自不同控件的事件 [英] re-using events from a different control

查看:81
本文介绍了重新使用来自不同控件的事件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的旧控件有按钮和事件,



此控件将包含在另一个控件中,并且应删除旧按钮。



在父控件中创建新按钮,它们应具有与以前相同的功能。



控件不会被继承。



我可以将旧事件公开并重复使用吗?

My old control had buttons with events,

This control will be included inside another one, and the old buttons should be removed.

New buttons are created in the parent control, they should have the same functionality as before.

Control is not inherited.

Can I make old events public and re-use them?

推荐答案

否 - 但你可以创建新事件并在封装控件处理旧事件时引发它们。



直接公开公开封装控件事件的唯一方法是make整个控制公众 - 这是一个非常非常糟糕的做法!
No - but you can create new events and raise them when the "old" ones are handled by the encapsulating control.

The only way to publicly expose the encapsulated control events directly would be to make the whole control public - and that's a very, very bad practice!


这篇关于重新使用来自不同控件的事件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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