Edit

Share via


'AddHandler' and 'RemoveHandler' method parameters must have the same delegate type as the containing event

A Custom Event declaration must have AddHandler or RemoveHandler declarations, each of which takes a single parameter of the delegate type specified by the custom event's As clause.

Error ID: BC31136

To correct this error

  • Change the type of the parameter to be the same as the delegate type specified by the custom event's As clause.

Example

This example shows a custom event with the correct parameter types for the AddHandler and RemoveHandler declarations.

VB
Custom Event Test As System.EventHandler
    AddHandler(ByVal value As System.EventHandler)
        ' Code for adding an event handler goes here.
    End AddHandler

    RemoveHandler(ByVal value As System.EventHandler)
        ' Code for removing an event handler goes here.
    End RemoveHandler

    RaiseEvent(ByVal sender As Object, ByVal e As EventArgs)
        ' Code for raising an event goes here.
    End RaiseEvent
End Event

See also