简体   繁体   English

放置其他控件时未触发表单事件

[英]Form events not fired when other control is in place

I have an application that contains a form with multiple controls. 我有一个包含包含多个控件的窗体的应用程序。

I have subscribed to the form mouse up event. 我已经订阅了鼠标上移事件。 However when I click on the form if thewre is an other control placed on the form the event is not fired. 但是,如果在窗体上放置了其他控件,则单击窗体时不会触发该事件。

So, I would like to capture an form event on the form (even when an control is in place). 因此,我想捕获表单上的一个表单事件(即使有一个控件也是如此)。 Is this possible? 这可能吗?

Thanks in advance. 提前致谢。

As far as i know windows forms doesn't implement the concept of event bubbling. 据我所知,Windows窗体没有实现事件冒泡的概念。 So you should manually tweak controls to handle the event. 因此,您应该手动调整控件以处理事件。 You can do it manually looping through all controls, or you can create some kind of wrapper for your form/container to subscribe to the event automatically. 您可以手动循环遍历所有控件,也可以为表单/容器创建某种包装器以自动订阅事件。 You may check general implementation of this idea here . 您可以在此处检查此想法的一般实现。 .

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM