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

dbTexts side by side

edited March 2002 in General
Hi Everybody,

My problem is: I have a report with many dbtexts side by side. How to
determine their width? I mean, I don?t want a part of a text above another
text. Is there any property as we have for many elements in a vertical way
similar to "relative to"? Well...I don?t know if I make myself clear... I
hope so!
Thanks a lot!!!

Bruno Nepomuceno

Comments

  • edited March 2002
    You can use the printer canvas to accurately measure the text which is
    coming from the datapipeline for the current record. Try this code out:

    uses
    ppTypes, ppUtils;

    procedure TForm1.ppDetailBand1BeforePrint(Sender: TObject);
    var
    lCanvas: TCanvas;
    lsText: String;
    ldWidth: Double;
    ldSpace: Double;
    begin

    ppDBText1.Left := 0;

    lsText := ppReport1.DataPipeline.GetFieldAsString(ppDBText1.DataField);

    lCanvas := ppReport1.Printer.Canvas;

    lCanvas.Font := ppDBText1.Font;

    ldWidth := lCanvas.TextWidth(lsText);

    ldWidth := ppToMMThousandths(Round(ldWidth), utPRinterPixels,
    pprtHorizontal, ppReport1.Printer);

    ldWidth := ppFromMMThousandths(Round(ldWidth), ppReport1.Units,
    pprtHorizontal, ppReport1.Printer);

    ppDBText1.Width := ldWidth;

    ldSpace := 0.25;{inches in my report}

    ppDBText2.Left := ppDBText1.Left + ppDBText1.Width + ldSpace;

    end;



    Cheers,

    Jim Bennett
    Digital Metaphors

This discussion has been closed.