RaiseEvent from a UserControl that's placed on

2019-09-04 05:25发布

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条回答
兄弟一词,经得起流年.
2楼-- · 2019-09-04 05:47

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.

查看更多
登录 后发表回答