Home General
New Blog Posts: Merging Reports - Part 1 and Part 2

Can I use the Username instaed Name.

edited February 2003 in General
I need to change the caption of the label at runtime, where the name of the
label defined in the reports is ppLabel1 and the username is FromDate,

TppFooterBand(FindComponent('ppLabel1')).Caption := '01/04/2003'

I need to use the username instaed the name property. Can I ? if so, how
should it be done ?

Thanks in Advance

Moorthy
~~~~~~

Comments

  • edited February 2003
    Perform a report object loop instead of a FindComponent call. This gives you
    full control over what you are looking for. See the tech-tips newsgroup for
    an article describing this technique. It should be located in the Code Based
    thread of that newsgroup.


    Cheers,

    Jim Bennett
    Digital Metaphors


  • edited February 2003
    Thanks for the info. You meant something like this right ?
    for i := 0 to ComponentCount - 1 do
    if (Components[i] is TppLabel) then
    begin
    if (Components[i] as TppLabel).UserName = 'Label6' then
    (Components[i] as TppLabel).Caption := _FromDATE;
    if (Components[i] as TppLabel).UserName = 'Label8' then
    (Components[i] as TppLabel).Caption := _ToDATE;
    end;

    But I thought this is too lengthy ! :) thats why I opt for a shoter
    solution. Also there is no "Code Based" thread in the tech-tips news-group.

    Thanks.



  • edited February 2003
    Try setting your newsreader to read older messages.


    ----------------------------------------------
    Tech Tip: Loop Thru All Objects in a Report
    ---------------------------------------------

    A ReportBuilder report is composed of a set
    of components. The basic structure is

    Reports.Bands[].Objects[]

    The bands and objects within the report can
    be accessed directly by object name or
    via the Bands and Objects array properties.

    Below is an example of using the Bands and
    Objects array properties to change the font for
    all objects on a report.


    uses
    ppClass;


    procedure AssignFontToReport(aFont: TFont; aReport: TppCustomReport);
    var
    liBand: Integer;
    liObject: Integer;
    lObject: TppComponent;

    begin

    for liBand := 0 to aReport.BandCount-1 do

    for liObject := 0 to aReport.Bands[liBand].ObjectCount-1 do
    begin
    lObject := aReport.Bands[liBand].Objects[liObject];

    if lObject.HasFont then
    lObject.Font := aFont;

    end;

    end;


    Cheers,

    Jim Bennett
    Digital Metaphors


  • edited February 2003
    Thanks.
    Can u please tell me how to set my newsreader to read older messages, Im
    using Outlook Express and could'nt figure out how that can be done.

    Sorry ! If Im going little out of the way. Thanks.



  • edited February 2003
    In OE, under Tools | Options | Maintenance dialog, there is a checkbox
    saying Delete news message [5] days after being downloaded. Uncheck this
    and redownload the tech-tips newsgroup. That should do the trick.


    Cheers,

    Jim Bennett
    Digital Metaphors


  • edited February 2003
    Thanks, it works.


This discussion has been closed.