Search code examples
.netwinformseventsmethodsdelphi-prism

How to make an event empty again?


If you have an Winform MouseDown event set to a method, how do you empty or reset the event. so that it has no methods to call when it fires.

Take for instance:

MouseDown += new System.Windows.Forms.MouseEventHandler(@SelectMouseDown);

And you want to reset MouseDown event to nothing or nil or null.

I think I was eluded to do the following by some other StackOverflow question.

MouseDown -= System.Windows.Forms.MouseEventHandler(@SelectMouseDown);

It doesn't work.


Solution

  • Did not do any tests, but this should do the job. Add the "new" to start of the line

    MouseDown -= new System.Windows.Forms.MouseEventHandler(@SelectMouseDown);