The behaviour is quite strange but you can do the following:
Option Strict On
Public Class Form1
Private Event NewClick(sender As Object, e As MouseEventArgs)
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
RaiseEvent NewClick(sender, CType(e, MouseEventArgs))
End Sub
Private Sub NewClickHandler(sender As Object, e As MouseEventArgs) Handles Me.NewClick
MsgBox(e.X & "x" & e.Y & vbCrLf & e.Button.ToString)
End Sub
End Class
You basically handle the correct signature, cast e
to MouseEventArgs
and then reraise a custom event that has a signature with MouseEventArgs
.
Edit:
I have dug around a bit in the System.Windows.Forms.Control
class and the reason that this works is, that the control's OnClick
event is actually raised with a MouseEventArgs
and not a simple EventArgs
. It's just then cast to EventArgs
(which obviously works since MouseEventArgs
inherits from EventArgs
).
From the Control
code:
If flag AndAlso Not AddressOf Me.ValidationCancelled Then
If Not Me.GetState(67108864) Then
Me.OnClick(New MouseEventArgs(button, clicks, NativeMethods.Util.SignedLOWORD(AddressOf m.LParam), NativeMethods.Util.SignedHIWORD(AddressOf m.LParam), 0))
Me.OnMouseClick(New MouseEventArgs(button, clicks, NativeMethods.Util.SignedLOWORD(AddressOf m.LParam), NativeMethods.Util.SignedHIWORD(AddressOf m.LParam), 0))
Else
'...
End If
End If