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
Solved

Dynamic reference to component name

Posted on 2003-11-28
3
351 Views
Last Modified: 2010-08-05
Hi,  I have a question that is probably quite simple, but beyond my scope of understanding yet.  I have a report that I wish to access a number of QRLabels at runtime.  I would like to loop through that which will be the references for the strings I wish to assign to each QRlabel.caption property.  I don't, however, know how I can dynamically reference a label.  For example,

for x := 0 to PageControl1.PageCount - 1 do;
  begin
    PageControl1.TabIndex := x;
   { y := x + 1;  y was to act as the changing variable for the label}
    frmSchedule.QRlbl_Date1.Caption := 'Week of '+ PageControl1.ActivePage.Caption;
  end;

As you can see, what I would like to change dynamically is the QRlbl_Date1 label to ..Date2, Date3, etc.  The Tab captions are dynamic and can change, so it's not a series of strings that can be hard coded.  Any help would be appreciated.
0
Comment
Question by:tonydm
3 Comments
 
LVL 5

Accepted Solution

by:
Darth_helge earned 25 total points
ID: 9842165
you can use the findcomponent method.
like this:

for x := 0 to PageControl1.PageCount - 1 do;
  begin
    PageControl1.TabIndex := x;
 with TLabel(FindComponent('QRlbl_Date' + IntToStr(x+1))) do
    Caption := 'Week of '+ PageControl1.ActivePage.Caption;
  end;

hope this helps

helgesen
0
 

Author Comment

by:tonydm
ID: 9842823
helgesen,

Thanks so much!  I am a novice trying to learn by jumping feet first.  This forum and all it members are such a great support and service.  Thanks again!

Tony
0
 

Expert Comment

by:thegetta
ID: 9843671
listening
0

Featured Post

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone 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

Suggested Solutions

Have you ever had your Delphi form/application just hanging while waiting for data to load? This is the article to read if you want to learn some things about adding threads for data loading in the background. First, I'll setup a general applica…
In my programming career I have only very rarely run into situations where operator overloading would be of any use in my work.  Normally those situations involved math with either overly large numbers (hundreds of thousands of digits or accuracy re…
In a recent question (https://www.experts-exchange.com/questions/29004105/Run-AutoHotkey-script-directly-from-Notepad.html) here at Experts Exchange, a member asked how to run an AutoHotkey script (.AHK) directly from Notepad++ (aka NPP). This video…

860 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