[2 days left] What’s wrong with your cloud strategy? Learn why multicloud solutions matter with Nimble Storage.Register Now

x
?
Solved

How can I access a control name using strings?

Posted on 1998-11-23
5
Medium Priority
?
133 Views
Last Modified: 2010-04-04
I want to be able to use a piece of code for several controls and use the 'Sender' information to accomplish this.

The code looks like this...

>>procedure TMyForm.udnLabelWidthUpClick(Sender: TObject);
>>begin
>>txtLabelWidth.Text := Floattostr(strtoFloat(txtLabelWidth.Text) + (1 / MeasureScale));
>>end;

I would like to be able to access the 'txtLabelWidth' control using the name of the 'UpDown' control. i.e. removing the first three letters of the 'udnLabelWidth' and adding 'txt' to it. And then use the string to access the control.

Thanks in advance
0
Comment
Question by:JasonC
[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
5 Comments
 
LVL 2

Accepted Solution

by:
lortega earned 800 total points
ID: 1347696
var
 myName :STring

MyName := (Sender as TEdit).name
0
 
LVL 2

Expert Comment

by:lortega
ID: 1347697
ups...

then
if  MyName = 'Upn...'
    then...{Do in one way}
    else...{Do in another way}


0
 
LVL 2

Expert Comment

by:lortega
ID: 1347698
ups...

then
if  MyName = 'Upn...'
    then...{Do in one way}
    else...{Do in another way}


0
 
LVL 7

Expert Comment

by:ahalya
ID: 1347699
following code spinpet would work assuming that you are using "SpinButtons". you can modify it as needed:

if (Sender is TSpinButton) then s := (Sender as TSpinButton).Name;
delete(s, 1, 3);
insert('txt', s, 1);
C := FindComponent(s);
(C as TEdit).Text := 'whatever...';


0
 
LVL 7

Expert Comment

by:ahalya
ID: 1347700
sorry, i didn't see the answers/comments when posting my comment.
0

Featured Post

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

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…
In this tutorial I will show you how to use the Windows Speech API in Delphi. I will only cover basic functions such as text to speech and controlling the speed of the speech. SAPI Installation First you need to install the SAPI type library, th…
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…
We’ve all felt that sense of false security before—locking down external access to a database or component and feeling like we’ve done all we need to do to secure company data. But that feeling is fleeting. Attacks these days can happen in many w…
Suggested Courses

649 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