Solved

Dynamic reference to component name

Posted on 2003-11-28
3
353 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
[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 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: 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

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…
Hello everybody This Article will show you how to validate number with TEdit control, What's the TEdit control? TEdit is a standard Windows edit control on a form, it allows to user to write, read and copy/paste single line of text. Usua…
In an interesting question (https://www.experts-exchange.com/questions/29008360/) here at Experts Exchange, a member asked how to split a single image into multiple images. The primary usage for this is to place many photographs on a flatbed scanner…
Are you ready to implement Active Directory best practices without reading 300+ pages? You're in luck. In this webinar hosted by Skyport Systems, you gain insight into Microsoft's latest comprehensive guide, with tips on the best and easiest way…

734 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