Solved

Addressing controls who's name is in a variable

Posted on 1998-09-12
2
134 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

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

Suggested Solutions

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…
Objective: - This article will help user in how to convert their numeric value become words. How to use 1. You can copy this code in your Unit as function 2. than you can perform your function by type this code The Code   (CODE) The Im…
In an interesting question (https://www.experts-exchange.com/questions/29008360/) here at Experts Exchange, a member asked how to split a single image into multiple images. The primary usage for this is to place many photographs on a flatbed scanner…
I've attached the XLSM Excel spreadsheet I used in the video and also text files containing the macros used below. https://filedb.experts-exchange.com/incoming/2017/03_w12/1151775/Permutations.txt https://filedb.experts-exchange.com/incoming/201…

763 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