Link to home
Start Free TrialLog in
Avatar of ChrisBerry
ChrisBerryFlag for United Kingdom of Great Britain and Northern Ireland

asked on

Addressing controls created at runtime

Hi,

I am creating a number of controls on a form at runtime. I am storing pointers to these controls in a TList on creation.

How do I use the entries in TList to access the properties and methods of the control or do I even need to do this to access the properties of the controls?

Thanks
Avatar of BlackMan
BlackMan

You need to typecast them, like TButton(MyList[1]).Caption. That also means that you need to know what type the objects are, otherwise you can typecast them to the lowest common object and use the properties defined on that object (f.ex. TComponent)
Avatar of ChrisBerry

ASKER

Thanks, just what I wanted.

Just one thing - why when a property/event like OnMouse... is declared in the heirarchy at the TObject or TWinObject (I forget which) can I only access it at the, say, TEdit level?

Please lock the question so I can hand you the points.

Regards

Chris

To your second question - because the lower level components publish these properties that were previously declared public or protected...
To your second question - because the lower level components publish these properties that were previously declared public or protected...
Thanks chrismo,

I wish to reject your answer because BlackMan gave the main answer I was looking for. If he does not lock within the next day or so please feel free to lock again and I will pass the points to you.


ASKER CERTIFIED SOLUTION
Avatar of BlackMan
BlackMan

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
No problem - I didn't realized I posted twice - I meant to just post a comment as I knew I wasn't answering the main question.