Solved

Addressing controls who's name is in a variable

Posted on 1998-09-12
2
136 Views
Last Modified: 2010-04-06
How can I address the properties of a control whose name I have in a variable?

I have tried something like this:-

TControl(ControlName).Property := xxxx;

While compiles happily I get an address error on run. I realsie I am apparently typecasting the ControlName variable to TControl and this is probably the cause of the error but I can't see the way to solve the problem.

Thanks

Chris
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
2 Comments
 
LVL 2

Accepted Solution

by:
rene100 earned 50 total points
ID: 1339500
try the FindComponent Method.
Example for a form with a TLabel named label1 on it:

procedure TForm1.Button1Click(Sender: TObject);
var
a: string;
b: TComponent;
begin
a:='label1';
b:=Findcomponent('label1');
(b as Tlabel).caption:='NewText';
end;

regards
rene
0
 

Author Comment

by:ChrisBerry
ID: 1339501
Thank you, I had implemented a find component using the component list of the form but I thought there must be a better way.


0

Featured Post

On Demand Webinar: Networking for the Cloud Era

Ready to improve network connectivity? Watch this webinar to learn how SD-WANs and a one-click instant connect tool can boost provisions, deployment, and management of your cloud connection.

Question has a verified solution.

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

Hello everybody This Article will show you how to validate number with TEdit control, What's the TEdit control? TEdit is a standard Windows edit control on a form, it allows to user to write, read and copy/paste single line of text. Usua…
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…
Come and listen to Percona CEO Peter Zaitsev discuss what’s new in Percona open source software, including Percona Server for MySQL (https://www.percona.com/software/mysql-database/percona-server) and MongoDB (https://www.percona.com/software/mongo-…
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 …

707 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