Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Dynamic reference to component name

Posted on 2003-11-28
3
Medium Priority
?
356 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 100 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

Vote for the Most Valuable Expert

It’s time to recognize experts that go above and beyond with helpful solutions and engagement on site. Choose from the top experts in the Hall of Fame or on the right rail of your favorite topic page. Look for the blue “Nominate” button on their profile to vote.

Question has a verified solution.

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

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…
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…
This Micro Tutorial will teach you how to add a cinematic look to any film or video out there. There are very few simple steps that you will follow to do so. This will be demonstrated using Adobe Premiere Pro CS6.
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…

783 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