Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Access a button via a string variable

Posted on 1999-07-05
9
Medium Priority
?
130 Views
Last Modified: 2010-04-06
How do i access the properties of Button1 if my string variable (aString) = 'Button1'?
ex.  
var aString:String;
begin
  aString := 'Button1';
  TButton(aString).Enabled := False;
end;
0
Comment
Question by:jonroul
[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
  • 8
9 Comments
 
LVL 13

Accepted Solution

by:
Epsylon earned 360 total points
ID: 1386319
FindComponent('Button1');
0
 
LVL 13

Expert Comment

by:Epsylon
ID: 1386320
Actually:

var theButton: TButton;

theButton := FindComponent('Button1');

0
 
LVL 13

Expert Comment

by:Epsylon
ID: 1386321
var b: TButton;
begin
  b := TButton(FindComponent('Button10'));
  b.caption := 'Hi';
end;

0
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 
LVL 13

Expert Comment

by:Epsylon
ID: 1386322
Hehe, in 4 attempts. That must be my record  :o)

and of course  b.Enabled := False;
0
 
LVL 13

Expert Comment

by:Epsylon
ID: 1386323
This will work too. It simulates a mouse click on Button7:

TButton(FindComponent('Button7')).Click;
0
 

Author Comment

by:jonroul
ID: 1386324
Thanks for the quick response. because of such an extra 25 points have been added.


0
 
LVL 13

Expert Comment

by:Epsylon
ID: 1386325
Thanks, that's very nice of you  :o)

Here is more interesting stuff. Maybe you can use it in the future.....
0
 
LVL 13

Expert Comment

by:Epsylon
ID: 1386326
0
 
LVL 13

Expert Comment

by:Epsylon
ID: 1386327
By the way, I guess you didn't know this:

When grading a question an A means the amount of point times 4. B is times 3, etc....

I got a B from you: 125 * 3 = 375

If you didn't raise the points with 25 and graded me an A, I would have got 400 points. A little waste.....

Cheers,

Epsylon
0

Featured Post

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

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

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…
Creating an auto free TStringList The TStringList is a basic and frequently used object in Delphi. On many occasions, you may want to create a temporary list, process some items in the list and be done with the list. In such cases, you have to…
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…
Want to learn how to record your desktop screen without having to use an outside camera. Click on this video and learn how to use the cool google extension called "Screencastify"! Step 1: Open a new google tab Step 2: Go to the left hand upper corn…
Suggested Courses

722 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