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

Detect last line in group

edited May 2003 in General
How can I have a label printed only on the last line in a group. Something
like "Label5.Visible := Group.LastRecord".

Thanks

-Jack

Comments

  • edited May 2003
    Why don?t you just use the group footer section?

    --
    Guillermo Casta?o A.
    www.GrupoMillennium.com
  • edited May 2003
    I has to be printed on the same line as the detail.
    -Jack

  • edited May 2003
    You can do this by letting the group finish generation and then display the
    data by creating draw commands that are inline with the last detail band of
    a group. Here is an example:
    http://www.digital-metaphors.com/tips/DrawGroupSumInLastDetail.zip


    Cheers,

    Jim Bennett
    Digital Metaphors


  • edited May 2003
    Jim,

    Thanks for the example. I needed it to work in RAP, but I found an example
    named RAPDrawCommandFunctions, and I was able to do the same with
    TppDrawText.

    I can't figure why the width is calculating just a bit short. For instance
    when the functions is called like this:
    AddDrawText(Report, '$39,149.40', DBCalc1.Font, 146350, 63499), the right
    most '40' is not printing. I would greatly appreciate if you could show me
    what I'm missing. (DBCalc1 is an Invisible component residing in the group
    footer).

    BTW, I was thinking if there isn't any way of taking a component residing in
    the footer and change it's position to where I'm trying to create the
    ppDrawText , instead of recreating one.


    TIA

    -Jack

    The signature is:
    'function AddDrawText(Report: TppReport; aText: string; Font: TFont;
    nLeft, nTop: Integer): TppDrawText;';

    procedure TcdAddDrawText.ExecuteFunction(aParams: TraParamList);
    var
    lReport: TppReport;
    lsText: string;
    liHeight, liLeft, liWidth, liTop: Integer;
    lDrawText: TppDrawText;
    lCanvas: TCanvas;
    lFont: TFont;
    begin

    GetParamValue(0, lReport);
    GetParamValue(1, lsText);
    GetParamValue(2, lFont);
    GetParamValue(3, liLeft);
    GetParamValue(4, liTop);

    lDrawText := TppDrawText.Create(nil);
    lDrawText.Page := lReport.Engine.Page;
    lDrawText.Text := lsText;
    lDrawText.Font := lFont;

    lDrawText.Left := liLeft;

    lCanvas := lReport.Printer.Canvas;

    lCanvas.Font := lDrawText.Font;

    liHeight := lCanvas.TextHeight(lDrawText.Text);
    liHeight := ppToMMThousandths(liHeight, utPrinterPixels, pprtVertical,
    lReport.Printer);

    lDrawText.Height := liHeight;

    lDrawText.Top := liTop - liHeight;

    liWidth := lCanvas.TextWidth(lDrawText.Text);
    liWidth := ppToMMThousandths(liWidth, utPrinterPixels, pprtHorizontal,
    lReport.Printer);

    lDrawText.Width := liWidth;

    SetParamValue(1, lDrawText);
    end;
  • edited May 2003
    Set TppDrawText.Autosize to true or increase its width.


    Cheers,

    Jim Bennett
    Digital Metaphors


This discussion has been closed.