redirect an event in VB.NET
Posted
by serhio
on Stack Overflow
See other posts from Stack Overflow
or by serhio
Published on 2010-03-16T15:39:27Z
Indexed on
2010/03/16
15:41 UTC
Read the original article
Hit count: 291
vb.net
I havea a UserControl1 (in witch I have an Label1) in Form1. I want to catch the MouseDown event from label and send it like from UserControl
I do:
Public Class UserControl1
Shadows Custom Event MouseDown As MouseEventHandler
AddHandler(ByVal value As MouseEventHandler)
AddHandler Label1.MouseDown, value
End AddHandler
RemoveHandler(ByVal value As MouseEventHandler)
RemoveHandler Label1.MouseDown, value
End RemoveHandler
RaiseEvent(ByVal sender As Object, ByVal e As MouseEventArgs)
'RaiseMouseEvent(Me, e) ??? '
End RaiseEvent
End Event
End Class
However, when I set in the Form1 the UserControl
Private Sub UserControl11_MouseDown(ByVal sender As System.Object, _
ByVal e As System.Windows.Forms.MouseEventArgs) _
Handles UserControl11.MouseDown
MessageBox.Show(sender.GetType.Name) 'here I have 'Label', want 'UserControl'
End Sub
© Stack Overflow or respective owner