h1.post-title { color:orange; font-family:verdana,Arial; font-weight:bold; padding-bottom:5px; text-shadow:#64665b 0px 1px 1px; font-size:32px; } -->

Pages

Custom Event in VB.Net

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