«« Site Rescued »»

While the site is still going to move from its current host, a new site will now take its place. More Info.

The new site may have less content, but the core will now remain. And it will now play nicely with phones! Keep an eye on the DelphiDabbler Blog for news.

» 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) ;
begin
  ShowMessage('Who clicked?') ;
  //remove event handler from event
  Button1.OnClick := nil;
end;

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 »