[Last Call] Learn about multicloud storage options and how to improve your company's cloud strategy. Register Now

x
?
Solved

passing a string as a component name

Posted on 2002-04-15
6
Medium Priority
?
257 Views
Last Modified: 2010-04-04
hi,
I have a form with 100 checkboxes and some images on it.
they are named A1,A2,A3,A4,A5,A6 Etc..and B1,B2 ,B3

i declare a type

Type
  THackCheckbox = class(TCheckbox);

also declare THackimage = class(TImage)

for instance a string var s is  = A4 (which is name of component)

so now i could do

 THackCheckbox(A4).SetChecked(True) and it works ok

but i need to do

 THackCheckbox(s).SetChecked(True)
or
THackImage(s).MouseDown(mbleft,[],THackImage(s).left,THackImage(s).top)

which both fails miserably with some message about s is not a component name .

i tried  various "as component"  etc but no luck,is it possible to pass string as component name like this?
im sure ive seen this done before by simonet but cant find relevent q.

Regards Barry
0
Comment
Question by:inthe
[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
6 Comments
 
LVL 27

Accepted Solution

by:
kretzschmar earned 300 total points
ID: 6941612
what about

var
 cb : thackcheckbox;
begin
 cb := findcomponent('yourString');
 if cb <> nil then
   cb.setchecked(true);
end;

meikl ;-)
0
 
LVL 9

Expert Comment

by:ITugay
ID: 6941617
Hi Barry,

do you mean somethong like this?

var
  C: TComponent;
begin
  C := FindComponent('CheckBox5');
  if C is TCheckBox then
    (C as TCheckBox).Checked := True;
end;

0
 
LVL 9

Expert Comment

by:ITugay
ID: 6941620
too late :-)
0
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 
LVL 27

Expert Comment

by:kretzschmar
ID: 6941628
would i not say, igor,
even my code was from head,
and i see at your code,
that i've done a mistake
(cb must be tcomponent->i guess)

meikl ;-)
0
 
LVL 9

Expert Comment

by:ITugay
ID: 6941646
hi meikl:-)

seems it doesn't matter in this case. Magic word was "FindComponent".

------
Igor.
0
 
LVL 17

Author Comment

by:inthe
ID: 6941682
ahhh yes findomponent will do it
0

Featured Post

Ask an Anonymous Question!

Don't feel intimidated by what you don't know. Ask your question anonymously. It's easy! Learn more and upgrade.

Question has a verified solution.

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

The uses clause is one of those things that just tends to grow and grow. Most of the time this is in the main form, as it's from this form that all others are called. If you have a big application (including many forms), the uses clause in the in…
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 this video you will find out how to export Office 365 mailboxes using the built in eDiscovery tool. Bear in mind that although this method might be useful in some cases, using PST files as Office 365 backup is troublesome in a long run (more on t…
In a question here at Experts Exchange (https://www.experts-exchange.com/questions/29062564/Adobe-acrobat-reader-DC.html), a member asked how to create a signature in Adobe Acrobat Reader DC (the free Reader product, not the paid, full Acrobat produ…
Suggested Courses

650 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