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

Dynamically hide a layer

edited August 2012 in General
Dear NG,

how can I dynamically hide a design layer at runtime in code?
I tried smething like

PriceLayer.Visible := False

but it all did not work.
Is it posisble at all?

Thanks,

Stephan

Comments

  • edited August 2012

    You can use the DesignLayer.LayerOptions to control which designer options
    are available to the end-user. You can set this at Delphi design-time or via
    code. See the RBuilder help topic for TppDesignLayer LayerOptions for
    details. (There is also a ComponentOptions property that can be used to
    control end-user editing options).

    Examples:

    // remove visible option
    PriceLayer.LayerOptions := PriceLayer.LayerOptions - [loVisible];

    // remove all options
    PriceLayer.LayerOptions := [];


    -
    Nard Moseley
    Digital Metaphors
    www.digital-metaphors.com

    Best regards,

    Nard Moseley
    Digital Metaphors
    www.digital-metaphors.com
  • edited August 2012
    Nard,

    Maybe I have a totally wrong understand of what design layers are used for.
    I thought I could put different elements on diffferent layers and then
    control the elements on one layer in one step.
    In my example I have a report that has some data and additionaly it
    might or might not show unit prices, total prices, and additional grand
    total and some sub totals on the prices.
    I put all these price related labels, ppDBText etc on a separate layer
    and in the Before Print event of the report (via RAP) I would like to
    run something like

    PriceLayer.Visible := what ever controls this.

    I do not want to control what can be done at desing time with these
    layers in the designer. I want to use the layer to hide or show all
    elements on that layer at once.
    I am not a developer in Delphi so I currently have no access to the help
    file.
    Am I completely wrong?

    Stephan



    Am 13.08.2012 16:29, schrieb Nard Moseley (Digital Metaphors):
    Nard,
  • edited August 2012
    We only provide tech support to Delphi developers that use ReportBuilder to
    add reporting functionality to their Delphi applications.


    -
    Nard Moseley
    Digital Metaphors
    www.digital-metaphors.com

    Best regards,

    Nard Moseley
    Digital Metaphors
    www.digital-metaphors.com
  • edited August 2012
    Nard,

    I just had a look at the help file (I am a developer...), and the first
    thing I saw was that the layer options are only relevant for the designer
    (just as you already said before). It seems that there is no chance to hide
    a complete layer at runtime (not just in the designer, but when the report
    is printed). So the layer component is not made for hiding a subset of
    components at all? What would be the best way to achieve something like
    that? The components I want to hide are spread over the whole report, some
    in the group header, some in the details, some in the summary. Is there any
    way to hide all these components at once?

    Thank you for your help,

    Christian


  • edited August 2012
    You can add predefined procedure in RAP with next functionality now.


    procedure SetLayerComponentsVisible(AReport: TppBandedReport; ALayer:
    TppDesignLayer;
    AValue: Boolean);
    var
    Band: TppBand;
    BandObject: TppComponent;
    I, J: Integer;
    begin
    for I := 0 to AReport.BandCount - 1 do
    begin
    Band := AReport.Bands[I];

    for J := 0 to Band.ObjectCount - 1 do
    begin
    BandObject := Objects[J];
    if (BandObject.DesignLayer = ALayer) then
    BandObject.Visible := AValue;
    end;
    end;
    end;

    PS. In RAP you can used ALayerUserName: string instead ALayer:
    TppDesignLayer.





    On Tue, 28 Aug 2012 13:28:59 +0300, Christian Schröder
  • edited August 2012

    I will add this to the requested feature list. The Design Layer concept is
    focused on facilitating editing of the report. Perhaps we can consider
    expanding it going forward.

    For now you can write a utility routine to accomplish this..

    uses
    ppClass,
    ppDesignLayer;

    procedure SetLayerVisible(aDesignLayer, aVisible)
    begin

    lComponents := TList.Create;

    aDesignLayer.GetComponents(lComponents);

    for liIndex := 0 to lComponents.Count-1 do
    TppComponent(lComponents[liIndex]).Visible := aVisible;

    lComponents .Free;

    end;


    -
    Nard Moseley
    Digital Metaphors
    www.digital-metaphors.com

    Best regards,

    Nard Moseley
    Digital Metaphors
    www.digital-metaphors.com
This discussion has been closed.