Solved

Dynamic reference to component name

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

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

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

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…
Introduction The parallel port is a very commonly known port, it was widely used to connect a printer to the PC, if you look at the back of your computer, for those who don't have newer computers, there will be a port with 25 pins and a small print…
Windows 10 is mostly good. However the one thing that annoys me is how many clicks you have to do to dial a VPN connection. You have to go to settings from the start menu, (2 clicks), Network and Internet (1 click), Click VPN (another click) then fi…
Two types of users will appreciate AOMEI Backupper Pro: 1 - Those with PCIe drives (and haven't found cloning software that works on them). 2 - Those who want a fast clone of their boot drive (no re-boots needed) and it can clone your drive wh…

813 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

15 Experts available now in Live!

Get 1:1 Help Now