Delphi Programming Question:
Download Questions PDF

Why do I get compile errors acessing the Sender object in events?

Answer:

If you look at the declaration, the Sender object is of type TObject, which is the class from which (almost) all other objects are derived. You're probably trying to access a property that isn't defined in TObject, like Text or Caption or something. For this reason, "Sender.Text" will fail, but if (for example) you know that the sender is of type TEdit, then you could use "(Sender As TEdit).Text". If you aren't certain that the Sender object will always be the same type, you can check it with "if (Sender is TEdit) then < blah> ;". See section 5.14.

Download Delphi Interview Questions And Answers PDF

Previous QuestionNext Question
How can I manipulate data programatically?Are there any tools to help me migrate my applications to Delphi?