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

calculate widths

edited November 2003 in General
hi,

i'd like to print a grid (detail subreport) with different # of columns
for each master. (maybe by setting visible to hide/show components).
but spread the columns printing to BestFit. (spread proportionaly)?

Comments

  • edited November 2003
    Hello,

    There is nothing built-in to ReportBuilder to do this. You will need set
    the certain DBText components Visible property to False in the cases you do
    not want to see that column, then based on the width of the page and your
    text, calculate the best fit width for each column at that given time.

    --
    Best Regards,

    Nico Cizik
    Digital Metaphors
    http://www.digital-metaphors.com
  • edited November 2003
    In article <3fa7e00d$1@dm500.>, "Nico Cizik \(Digital Metaphors\)"
  • edited November 2003
    ----------------------------------------------------------
    TECH TIP: Calculating the widths of components at run-time
    ----------------------------------------------------------

    The example below shows how to calculate the widths of
    report components and position them horizontally.

    This example procedure accepts a list of CustomText
    descendents and positions them flush left, one after
    the other. The Left position of the first component is
    used as the starting point.


    procedure ppAlignHorizontal(aComponentList: TList);
    var
    lCustomText: TppCustomText;
    lBitmap: TBitmap;
    liPosition := 0;

    begin

    if (aComponentList = nil) then Exit;

    if (aComponentList.Count = 0) then Exit;

    lBitmap := TBitmap.Create;
    liPosition := TppCustomText(aComponentList[0]).spLeft;

    for liIndex := 0 to aComponentList.Count - 1 do
    begin
    lCustomText := TppCustomText(aComponentList[liIndex]);

    {set components screen pixel left}
    lCustomText.spLeft := liPosition;

    {calc next position}
    lBitmap.Canvas.Font := lCustomText.Font;

    liTextWidth := lBitmap.Canvas.TextWidth(lComponent.Caption);

    liPosition := liPosition + liTextWidth;
    end;

    lBitmap.Free;

    end;

    --
    Best Regards,

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