问题描述
我有一个Windows窗体,它包含一个用户控件容器作为UserControl。为了这个问题,这个自定义控件容器叫做Dashboard。名为Dashboard的容器包含许多其他控件,具体取决于其权限。我需要通过Dashboard控件提交这些控件中包含的事件,并转到Windows窗体。
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.
我如何才能使事件发生爆炸?我在这个项目中使用VB.NET,但是可以将C#转换成VB.NET。
How can I bubble up the event? I'm using VB.NET for this project, but can convert C# into VB.NET.
另外,为了使问题复杂化,主窗体窗体是一个VB6项目。所以,我正在使用InteropFormsToolkit来完成这个。
Also, to complicate matters, the main Windows Form is a VB6 project. So, I'm using the InteropFormsToolkit to accomplish this.
推荐答案
我想出来了。我只是做了我所说的,我想做,并用自定义的eventargs类创建一个事件,并冒泡到VB6应用程序。每个控件需要实现自定义事件,例如:
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)
并继续将该事件提升到VB6。在VB6中,该事件作为一个功能被公开,以便我根据需要处理。
And continue raising that event up to VB6. In VB6 that event was exposed as a function for me to handle as necessary.
这篇关于从位于Form上UserControl上的UserControl的RaiseEvent的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!