EventHandlerExtensionsGetHandlerTDelegate Method

Gets the event handler of the specified type from the EventHandlerList instance.

Definition

Namespace: KGySoft.WinForms
Assembly: KGySoft.WinForms (in KGySoft.WinForms.dll) Version: 5.0.1
C#
public static TDelegate GetHandler<TDelegate>(
	this EventHandlerList? handlers,
	Object key
)
where TDelegate : Delegate

Parameters

handlers  EventHandlerList
The EventHandlerList instance to het the handler delegate from.
key  Object
The same key that is used for the AddHandler(Object, Delegate) and RemoveHandler(Object, Delegate) methods when the event is subscribed or unsubscribed.

Type Parameters

TDelegate
The delegate type of the event handler.

Return Value

TDelegate
The event handler delegate of the specified type, or if no such handler is found or the specified TDelegate type does not match.

Usage Note

In Visual Basic and C#, you can call this method as an instance method on any object of type EventHandlerList. When you use instance method syntax to call this method, omit the first parameter. For more information, see Extension Methods (Visual Basic) or Extension Methods (C# Programming Guide).

See Also