Home General

ShiftRelativeTo in code

edited June 2010 in General
Hi,
if i add a region in code to an existing report (loaded trough template)
and i alter the UserName of the region and then use this region of
ShiftRelative a ppMemo to this region, it does not work...
if i change the region.Name according to the Username it does work...

so
aRegion := TppRegion.create(nil);
aRegion.Band := ppTemp.SummaryBand;
aRegion.UserName := 'MyRegion';

aExistingMemo.ShiftRelativeTo := aRegion;

does not show in the designer that the memo is going to be shifted..
if i add
aRegion.Name := 'MyRegion';
all works well...

why?

tia,
marc

Comments

  • edited June 2010
    The VCL manages object references based on the Name property.

    The UserName is an additional concept we added to enable the end-user to
    change the display name at run-time. The Delphi help recommends not
    modifying the Name property at runt-time.

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



    Best regards,

    Nard Moseley
    Digital Metaphors
    www.digital-metaphors.com
  • edited June 2010
    i have to cause when you create a new region, this region gets an empty Name
    property
    if you do the same with a tppmemo, this memo gets a dummy name...

    additionally, UserName is the only way to be able to change a customized
    design in relation to a default one
    very handy to search for the default component
    and to set some properties in runtime, if the UserName is correct you always
    can find the component

    so for me it is far more handy and important than just have a nice display
    name!

    cu
    marc

  • edited June 2010
    I tried the code below, but there is no name assigned - which is fine. Also
    note that when creating components, the Owner should be the Report.Owner,
    which is typically the form/datamodule upon which the report component
    resides.


    var
    lMemo: TppMemo;
    begin
    lMemo := TppMemo.Create(ppReport1.Owner);
    lMemo.Band := ppReport1.DetailBand;

    lMemo.UserName := 'TestMemo';

    ShowMessage(lmemo.Name);



    There is a routine in ppUtils.pas, called ppGetUniqueName, you could try
    using that to generate a unique name.

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



    Best regards,

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