Quantcast
Channel: VBForums - Visual Basic .NET
Viewing all articles
Browse latest Browse all 27355

Addhandler for custon event with MouseEventArgs

$
0
0
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
Code:

Public Event PublicEventUserGram As EventHandler
Raising the Event in correct Event-Routine with the correct MyMouseEventArg by
Code:

RaiseEvent PublicEventUserGram(Me, MyMouseEventArg)
In the parent form:
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
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?

Viewing all articles
Browse latest Browse all 27355

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>