Solved

Dynamic reference to component name

Posted on 2003-11-28
3
347 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

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Suggested Solutions

This article explains how to create forms/units independent of other forms/units object names in a delphi project. Have you ever created a form for user input in a Delphi project and then had the need to have that same form in a other Delphi proj…
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…
This video discusses moving either the default database or any database to a new volume.
Excel styles will make formatting consistent and let you apply and change formatting faster. In this tutorial, you'll learn how to use Excel's built-in styles, how to modify styles, and how to create your own. You'll also learn how to use your custo…

707 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

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now