RaiseEvent from a UserControl that's placed on a UserControl that's on a Form

坚强是说给别人听的谎言 提交于 2019-12-12 01:03:43

问题


I have a Windows Form that contains a custom control container as a UserControl. For the sake of this question, this custom control container is called Dashboard. This container called Dashboard contains numerous other controls depending on their permissions. I need to raise events that are contained on these controls through the Dashboard control and over to the Windows Form.

How can I bubble up the event? I'm using VB.NET for this project, but can convert C# into VB.NET.

Also, to complicate matters, the main Windows Form is a VB6 project. So, I'm using the InteropFormsToolkit to accomplish this.


回答1:


I figured it out. I just did what I had said that I wanted to do and created an event with a custom eventargs class and bubbled it up to the VB6 app. Each control needed to implement the custom event such as:

Public Event OnMyCustomEvent(source As Object, e As MyCustomEventArgs)

And continue raising that event up to VB6. In VB6 that event was exposed as a function for me to handle as necessary.



来源:https://stackoverflow.com/questions/6656965/raiseevent-from-a-usercontrol-thats-placed-on-a-usercontrol-thats-on-a-form

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!