Custom Event in VB.Net
Here are the Example for Custom Event in VB.net
Here are the Example for Custom Event in VB.net
Dim _handlers As New List(Of EventHandler)
Public Custom Event AnyName As EventHandler
AddHandler(ByVal value As EventHandler)
AddHandler <Control Name>.<Event>, value
End AddHandler
RemoveHandler(ByVal value As EventHandler)
RemoveHandler <Control Name>.<Event>, value
End RemoveHandler
RaiseEvent(ByVal sender As Object, ByVal e As System.EventArgs)
For Each handler As EventHandler In _handlers
Try
handler.Invoke(sender, e)
Catch ex As Exception
Debug.WriteLine("Exception while invoking event handler: " & ex.ToString())
End Try
Next
End RaiseEvent
End Event
Public Custom Event AnyName As EventHandler
AddHandler(ByVal value As EventHandler)
AddHandler <Control Name>.<Event>, value
End AddHandler
RemoveHandler(ByVal value As EventHandler)
RemoveHandler <Control Name>.<Event>, value
End RemoveHandler
RaiseEvent(ByVal sender As Object, ByVal e As System.EventArgs)
For Each handler As EventHandler In _handlers
Try
handler.Invoke(sender, e)
Catch ex As Exception
Debug.WriteLine("Exception while invoking event handler: " & ex.ToString())
End Try
Next
End RaiseEvent
End Event