Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

(Sender:TObject)

Tags:

delphi

What does (Sender:TObject) mean?? As in:

procedure TForm1.Button1Click(Sender:TObject);

var
s: Integer;

begin
.....
.....
end;
like image 240
DrStrangeLove Avatar asked Dec 05 '22 03:12

DrStrangeLove


1 Answers

Sender is a reference to the component that fired the event. In this case, Sender is going to be the button the user clicked which called your Button1Click event.

This is useful when you have several components that call the same event and you need to figure out which component caused the event to be fired.

For instance, you could do something like:

if Sender = Button1 then
// ...
like image 180
Jeff Wilhite Avatar answered Jan 02 '23 11:01

Jeff Wilhite