Reputation: 535
I am trying to generate an event handler in windows form application. When I write
myAlgorithm.nextNodeFound +=
and press 'Tab' two times it generates a new handler automatically but this handler works on EventArgs, what I need is to have a handler that works with CustomEventArgs
. I tried to modify the signature of auto generated handler but then it gives the error
*No overload for myAlgo_nextNodeFound matches delegate System.EventHandler*
Please suggest how to make it work.
Upvotes: 1
Views: 120
Reputation: 1500893
It looks like the problem is that you've declared your nextNodeFound
event to be of type EventHandler
. If you need it to work with your custom args, you should use a delegate type which uses the right parameters... the generic EventHandler<TEventArgs>
type is probably what you want:
public event EventHandler<CustomEventArgs> NextNodeFound;
Note that I've changed the name of the comply with .NET naming conventions. This is also assuming that CustomEventArgs
derives from EventArgs
- if it doesn't already, I suggest you make it do so. You might also want to change the name to indicate how it's custom - such as NodeTraversalEventArgs
or something similar.
It sounds like you may be relatively new to .NET events - you might want to read my article on events and delegates.
Upvotes: 2