Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Help.. Global Exit Procedure for many items?

Status
Not open for further replies.

SpeedDemon

Programmer
Jan 1, 2001
70
GB
Hi, I have 5 drop down lists....

prod1 through to prod5

I need to do on onexit event for each object, how can I write the procedure once, but make all 5 run it?

Cheers all,.
 
Set up the OnExit event for prod1.

Now, click on prod2, and in the Object Inspector window click on events. Click _once_ in the right hand column next to OnExit, and a drop-down will appear. Click on the drop-down arrow, and select the procedure you've already written (probably prod1Exit). Repeat this for prod3, prod4, prod5.

If you like you could rename prod1Exit to prodExit to make it a bit more intuitive. If you do this in the Object Inspector, Delphi will magically change the name everywhere it needs to be changed.

If, in prodExit, you need to tell which of the five prod's called the routine, you can use the Sender object:

Code:
Sender.Visible := False;
will hide whichever prod called the OnExit;

Code:
if Sender = prod1 then
will test true iff prod1 caused the call to OnExit.

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top