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

Create a Component in the "BeforeGenerate" event of a generic Band

edited September 2005 in General
?I'd like to create a TppLabel in the BeforeGenerate Event of my
DetailBand, but also if I can find my new object in Objects list of the
detailband I can't find my Label in the report preview.
Could you help me?
I need a Method to add my TppLabel to the generated Objects of the
DetailBand.
Thank you



--- posted by geoForum on http://delphi.newswhat.com

Comments

  • edited September 2005
    Hi,

    The Band.BeforeGenerate fires too late to add a component to the report.
    One place you could do it would be the Report.BeforePrint event. Otherwise
    you will need to manually create a DrawCommand and add it to your report.
    Note that DrawCommands do not use report units, they are measured in
    microns. Below is a quick example of adding a drawcommand to the middle of
    a page.

    uses
    ppDrwCmd,
    ppUtils,
    ppTypes;

    var
    lDrawText: TppDrawText;
    begin

    lDrawText := TppDrawText.Create(nil);
    lDrawText.Text := 'ReportBuilder... there is no subsitute';
    lDrawText.Transparent := True;
    lDrawText.Font.Name := 'Arial';
    lDrawText.Font.Size := 18;
    lDrawText.Font.Color := clBlack;
    lDrawText.Autosize := True;

    lDrawText.Height := ppToMMThousandths(25, utScreenPixels, pprtHorizontal,
    nil);
    lDrawText.Width := ppToMMThousandths(100, utScreenPixels,
    pprtHorizontal, nil);

    lDrawText .Top := (lPrinter.PrinterSetup.PageDef.mmPrintableHeight -
    lDrawText .Height) div 2;
    lDrawText .Left := (lPrinter.PrinterSetup.PageDef.mmPrintableWidth -
    lDrawText.Width ) div 2;

    end;

    --
    Regards,

    Nico Cizik
    Digital Metaphors
    http://www.digital-metaphors.com

    Best Regards,

    Nico Cizik
    Digital Metaphors
    http://www.digital-metaphors.com
  • edited September 2005
    >Hi,
    report.
    Otherwise
    report.
    middle of
    pprtHorizontal,



    Could you send me an example please?



    --- posted by geoForum on http://delphi.newswhat.com
  • edited September 2005
    Hi,

    The following example shows how to add a DrawCommand to a page. You will do
    something similare only addng a DrawText instead of a DrawShape object.
    (Similar to the code I gave in my last post).

    http://www.digital-metaphors.com/tips/AddDrawCommandToPage.zip

    --
    Regards,

    Nico Cizik
    Digital Metaphors
    http://www.digital-metaphors.com

    Best Regards,

    Nico Cizik
    Digital Metaphors
    http://www.digital-metaphors.com
This discussion has been closed.