Solved

Addressing controls created at runtime

Posted on 1998-08-28
7
139 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
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 50 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

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!

Question has a verified solution.

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

Introduction The parallel port is a very commonly known port, it was widely used to connect a printer to the PC, if you look at the back of your computer, for those who don't have newer computers, there will be a port with 25 pins and a small print…
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…
Monitoring a network: how to monitor network services and why? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the philosophy behind service monitoring and why a handshake validation is critical in network monitoring. Software utilized …
This is my first video review of Microsoft Bookings, I will be doing a part two with a bit more information, but wanted to get this out to you folks.

688 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