Home General

Conditionally changing band height

edited August 2001 in General
I have a detail band on a subreport as follows:

[dbText1] [dbText2]
[dbText3]

In the OnPrint event of dbText3, I set that text component's Visible
property based on whether the data is Null.

If dbText3 is invisible, I don't want it to take up any vertical space
on the band.

I've tried changing dbText3's height in OnPrint, changing the band's
height in OnPrint (appeared to work, until I went back a page in
preview), using DynamicHeight for the band, etc. - nothing works.

(I do also have a vertical TppLine that's set to ParentHeight.)

Any suggestions? Someone must have encountered this before.
++++
Bill Sorensen, Programmer/Analyst, ASI/EDI Inc.
(opinions are mine alone)
bsorensen@asicentral.com
www.asiedi.com

Comments

  • edited August 2001
    (I do also have a vertical TppLine that's set to ParentHeight.)

    I'm not sure how to fix the issue with the dbtext but I can tell
    you how to fix the problem with tppline.
    Set your tppline so the height of the line is minimal, use top or
    bottom line, and set to shift with parent (not stretch with p).
    That will shift the line up whenever necessary.

    As far as your dbtext goes, I would try something like using a
    memo and setting the original height to 0, and stretch = true.
  • edited August 2001

    Try using the Band.BeforePrint event to check for Null and set
    Band.Height. Changing the band height should always be done in
    BeforePrint.




    Best regards,

    Nard Moseley
    Digital Metaphors
    www.digital-metaphors.com
  • edited August 2001
    Thanks to you and Mr. Packard for your suggestions.

    Using Band.BeforePrint worked. Here's what I did, if anyone else is
    interested:

    1. Set the band's PrintHeight to phStatic.

    2. In the report's BeforePrint event, saved off the original band
    height and the Top position of [dbText3].

    3. The band's BeforePrint event looks like this:

    procedure TFmAPRptIN.RbBandInvoiceLineDetailBeforePrint(Sender:
    TObject);
    begin
    if MyDataField.IsNull then
    begin
    [dbText3].Visible := False;

    RbBandInvoiceLineDetail.Height :=
    FOriginalLineItemDetailBandHeight - [dbText3].Height;

    end { if }
    else
    begin
    [dbText3].Visible := True;

    RbBandInvoiceLineDetail.Height :=
    FOriginalLineItemDetailBandHeight;

    [dbText3].Top := FOriginalQuantityBackOrderedTop;
    end; { else }
    end;

    Resetting Top was necessary, as when a previous band was resized, this
    would move [dbText3] upwards.

    This is quite a complex series of steps for something that should be
    relatively simple (and, I suspect, is fairly common). Please consider
    adding functionality to RB to simplify this. Thank you.

    On Fri, 3 Aug 2001 18:26:04 -0500 , "Nard Moseley (Digital Metaphors)"
This discussion has been closed.