?
Solved

Addressing controls created at runtime

Posted on 1998-08-28
7
Medium Priority
?
143 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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
Independent Software Vendors: 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

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!

Question has a verified solution.

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

This article explains how to create forms/units independent of other forms/units object names in a delphi project. Have you ever created a form for user input in a Delphi project and then had the need to have that same form in a other Delphi proj…
Have you ever had your Delphi form/application just hanging while waiting for data to load? This is the article to read if you want to learn some things about adding threads for data loading in the background. First, I'll setup a general applica…
In this brief tutorial Pawel from AdRem Software explains how you can quickly find out which services are running on your network, or what are the IP addresses of servers responsible for each service. Software used is freeware NetCrunch Tools (https…
How to fix incompatible JVM issue while installing Eclipse While installing Eclipse in windows, got one error like above and unable to proceed with the installation. This video describes how to successfully install Eclipse. How to solve incompa…
Suggested Courses
Course of the Month13 days, 18 hours left to enroll

800 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