How to clear an event handler?

  • Thread starter Thread starter Martin Hart - Memory Soft, S.L.
  • Start date Start date
M

Martin Hart - Memory Soft, S.L.

Hi:

I have a control on a WinForm that has a KeyDown handler assigned, but in a
different part of the program, where I don't have the actual handler that
was added (+=), I wish to empty the KeyDown handler. As I don't have the
actual handler to use with -=, how do I do this?

TIA,
Martin.
 
Create a delegate instance pointing to the same event handling routine the
delegate used with += points to and use it with -=.
Still, I'd recommend to keep event handler management in the same part of
the program.
 
Back
Top