?
Solved

Addressing controls created at runtime

Posted on 1998-08-28
7
Medium Priority
?
149 Views
Last Modified: 2012-05-04
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
0
Comment
Question by:ChrisBerry
  • 3
  • 2
  • 2
7 Comments
 
LVL 7

Expert Comment

by:BlackMan
ID: 1337994
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)
0
 

Author Comment

by:ChrisBerry
ID: 1337995
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

0
 

Expert Comment

by:chrismo
ID: 1337996
To your second question - because the lower level components publish these properties that were previously declared public or protected...
0
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

Expert Comment

by:chrismo
ID: 1337997
To your second question - because the lower level components publish these properties that were previously declared public or protected...
0
 

Author Comment

by:ChrisBerry
ID: 1337998
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.


0
 
LVL 7

Accepted Solution

by:
BlackMan earned 200 total points
ID: 1337999
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)
0
 

Expert Comment

by:chrismo
ID: 1338000
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.
0

Featured Post

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

A lot of questions regard threads in Delphi.   One of the more specific questions is how to show progress of the thread.   Updating a progressbar from inside a thread is a mistake. A solution to this would be to send a synchronized message to the…
Introduction I have seen many questions in this Delphi topic area where queries in threads are needed or suggested. I know bumped into a similar need. This article will address some of the concepts when dealing with a multithreaded delphi database…
this video summaries big data hadoop online training demo (http://onlineitguru.com/big-data-hadoop-online-training-placement.html) , and covers basics in big data hadoop .
As many of you are aware about Scanpst.exe utility which is owned by Microsoft itself to repair inaccessible or damaged PST files, but the question is do you really think Scanpst.exe is capable to repair all sorts of PST related corruption issues?
Suggested Courses
Course of the Month15 days, 19 hours left to enroll

850 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question