sebastian.
Member
- Joined
- Sep 20, 2009
- Messages
- 17
- Programming Experience
- 1-3
Hi everybody!
I have a problem with binding my EventHandlers at the right time.
Here's a pseudo code of my 1. version:
The event is raised during the initialization of my
Object, but it isn't captured by its EventHandler in the
...that's obvious, because the Handler is added to late.
But I have the same problem when I modify my code like this:
I thought this 2. version would use "static binding" of the events during compile time. But it seems, that they are also bound to late, namely after the initialization of my UserControl has finished and so they aren't captured again.
So is there a possibility to bind the events "at the beginning" so that my events, which are raised during the init of my UserControlClass are handled in my MainClass?
Thanks in advance!
Greetings, Sebastian
I have a problem with binding my EventHandlers at the right time.
Here's a pseudo code of my 1. version:
VB.NET:
Public Class MainClass
Public Sub Main()
Dim myUserControl as UserControlClass = new UserControlClass()
AddHandler myUserControl.myUserControlEvent, myUserControlEventHandler
End Sub
Private Sub myUserControlEventHandler()
...
End Sub
End Class
The event is raised during the initialization of my
VB.NET:
myUserControl
VB.NET:
MainClass
But I have the same problem when I modify my code like this:
VB.NET:
Public Class MainClass
Public Sub Main()
Dim WithEvents myUserControl as UserControlClass = new UserControlClass()
End Sub
Private Sub myUserControlEventHandler() Handles myUserControl.myUserControlEvent
...
End Sub
End Class
I thought this 2. version would use "static binding" of the events during compile time. But it seems, that they are also bound to late, namely after the initialization of my UserControl has finished and so they aren't captured again.
So is there a possibility to bind the events "at the beginning" so that my events, which are raised during the init of my UserControlClass are handled in my MainClass?
Thanks in advance!
Greetings, Sebastian