Notice Of Closure

Please note that this website is due to close down on 15th June 2020.

In the interim I will try to move as much content as possible over to my GitHub account. Thanks to everyone who has supported the site over the years.

» Help

How to detach and re-attach an event


If, for any reason, you want to detach (remove) the code you have written in an event handler, you have to set the event handler to nil.

procedure TForm1.Button1Click(Sender: TObject) ;
  ShowMessage('Who clicked?') ;
  //remove event handler from event
  Button1.OnClick := nil;

To re-assign the procedure Button1Click to the button's OnClick event, you should use:

Button1.OnClick := Button1Click;
Author: Shlomo Abuisak
Contributor: Shlomo Abuisak
Added: 2009-11-05
Last updated: 2009-11-05

« Return to contents »