I managed to to raise an event from a UserControl which is then handled in the MainForm (See this Thread)
I've done
In UserControl:
Declaring Public Event by
Raising the Event in correct Event-Routine with the correct MyMouseEventArg by
In the parent form:
Changing the PictureBox_MouseUp to be Private
When creating new instances of the UserControl adding the EventHandle by
However, I had Option Strict OFF in the MainForm. After selection it to ON, I get an error saying an implicit typeconversion from MouseEventArgs to EventArgs was needed.
If I declare the Public Event explicitly with "(ByVal sender As Object, ByVal e As MouseEventArgs)" I get an error that an event can't have a return value.
Do I need to create a Sub with perfect matching arguments in the mainform, that in turn changes to EventArg to a MouseEventArg an then calls the needed Sub?
Or is there a better way?
I've done
In UserControl:
Declaring Public Event by
Code:
Public Event PublicEventUserGram As EventHandler
Code:
RaiseEvent PublicEventUserGram(Me, MyMouseEventArg)
Changing the PictureBox_MouseUp to be Private
When creating new instances of the UserControl adding the EventHandle by
Code:
AddHandler NewUserGram.PublicEventUserGram, AddressOf PictureBox_MouseUp
If I declare the Public Event explicitly with "(ByVal sender As Object, ByVal e As MouseEventArgs)" I get an error that an event can't have a return value.
Do I need to create a Sub with perfect matching arguments in the mainform, that in turn changes to EventArg to a MouseEventArg an then calls the needed Sub?
Or is there a better way?