Created at runtime: Memos not added to their 'parents'

Hello FR Gurus.
I am creating a report at runtime, and while the report looks tidy when I send it to PDF, when I preview it in the designer it all goes awry.

Here is a part of the code where I create the PageHeader:
CreateStandardHeader(Title: String);
var
  Line : TfrxLineView;
begin
  fPageHeader := TfrxPageHeader.Create(fPage);
  fPageHeader.CreateUniqueName;
  fPageHeader.Stretched := TRUE;
  //Company
  With TfrxMemoView.Create(fPageHeader) do
  Begin
    CreateUniqueName;
    Align := baLeft;
    AutoWidth := TRUE;
    HAlign := TfrxHAlign.haLeft;
    SetBounds(0,4,0,30);
    StretchMode := smActualHeight;
    Text := dk_db.CurrentGeCompanyObject.CompanyId.AsString + ' - ' +
            dk_db.CurrentGeCompanyObject.Name.AsString + NewLineChar +
            FormattedDateTime(Now);
  End;

  //Title
  With TfrxMemoView.Create(fPageHeader) do
  Begin
    CreateUniqueName;
    Align := baCenter;
    AutoWidth := TRUE;
    HAlign := TfrxHAlign.haCenter;
    SetBounds(0,4,0,20);
    StretchMode := smActualHeight;
    Font.Size := 10;
    Font.Style := [fsBold];
    Text := Title;
  End;

  Line := TfrxLineView.Create(fPageHeader);
  Line.CreateUniqueName;
  Line.Top := 35;
  Line.Align := baWidth;
end;
But as you can see from the screenshots, the pageHeader stands alone, and the Memos are not added (i.e. Memo1, Memo2)

Comments

  • edited 4:17AM
    Gisli wrote: »
    Hello FR Gurus.
    I am creating a report at runtime, and while the report looks tidy when I send it to PDF, when I preview it in the designer it all goes awry.

    Here is a part of the code where I create the PageHeader:
    CreateStandardHeader(Title: String);
    var
      Line : TfrxLineView;
    begin
      fPageHeader := TfrxPageHeader.Create(fPage);
      fPageHeader.CreateUniqueName;
      fPageHeader.Stretched := TRUE;
      //Company
      With TfrxMemoView.Create(fPageHeader) do
      Begin
        CreateUniqueName;
        Align := baLeft;
        AutoWidth := TRUE;
        HAlign := TfrxHAlign.haLeft;
        SetBounds(0,4,0,30);
        StretchMode := smActualHeight;
        Text := dk_db.CurrentGeCompanyObject.CompanyId.AsString + ' - ' +
                dk_db.CurrentGeCompanyObject.Name.AsString + NewLineChar +
                FormattedDateTime(Now);
      End;
    
      //Title
      With TfrxMemoView.Create(fPageHeader) do
      Begin
        CreateUniqueName;
        Align := baCenter;
        AutoWidth := TRUE;
        HAlign := TfrxHAlign.haCenter;
        SetBounds(0,4,0,20);
        StretchMode := smActualHeight;
        Font.Size := 10;
        Font.Style := [fsBold];
        Text := Title;
      End;
    
      Line := TfrxLineView.Create(fPageHeader);
      Line.CreateUniqueName;
      Line.Top := 35;
      Line.Align := baWidth;
    end;
    

    Hi Gisli,

    You might want to try setting the Top property of the various bands so they come after each other (i.e. Title, Header, Databand) something like this :-
    Procedure TCustomReporter.CreateHeader;
    Begin
      FTitleBand := TfrxReportTitle.Create(FPage);
      FTitleBand.CreateUniqueName;
      FTitleBand.Top := 0;
      FTitleBand.Height := 100;
      FTitleBand.Width := FPage.Width;
      FTitleBand.SetBounds(0, 0, FPage.Width, 100);
    
      FHeaderBand := TfrxPageHeader.Create(FPage);
      FHeaderBand.CreateUniqueName;
      FHeaderBand.Top := FTitleBand.Height + 1;
      FHeaderBand.Height := 25;
      FHeaderBand.Width := FPage.Width;
      FHeaderBand.SetBounds(0, 0, FPage.Width, 25);
    End;
    
    Procedure TCustomReporter.CreateDetail;
    Begin
      FDataBand := TfrxMasterData.Create(FPage);
      FDataBand.CreateUniqueName;
      FDataBand.DataSet := FPipeline;
      FDataBand.Top := FHeaderBand.Height + 1;
      FDataBand.Height := 18;
      FDataBand.Width := FPage.Width;
      FDataBand.Stretched := True;
    End;
    
    

    Hope this helps,

    Regards,

    Andy
  • edited 4:17AM
    Thanks alot Andy, that did the trick.
    Gisli
    Andy_D wrote: »
    Hi Gisli,

    You might want to try setting the Top property of the various bands so they come after each other (i.e. Title, Header, Databand) something like this :-
    Procedure TCustomReporter.CreateHeader;
    Begin
      FTitleBand := TfrxReportTitle.Create(FPage);
      FTitleBand.CreateUniqueName;
      FTitleBand.Top := 0;
      FTitleBand.Height := 100;
      FTitleBand.Width := FPage.Width;
      FTitleBand.SetBounds(0, 0, FPage.Width, 100);
    
      FHeaderBand := TfrxPageHeader.Create(FPage);
      FHeaderBand.CreateUniqueName;
      FHeaderBand.Top := FTitleBand.Height + 1;
      FHeaderBand.Height := 25;
      FHeaderBand.Width := FPage.Width;
      FHeaderBand.SetBounds(0, 0, FPage.Width, 25);
    End;
    
    Procedure TCustomReporter.CreateDetail;
    Begin
      FDataBand := TfrxMasterData.Create(FPage);
      FDataBand.CreateUniqueName;
      FDataBand.DataSet := FPipeline;
      FDataBand.Top := FHeaderBand.Height + 1;
      FDataBand.Height := 18;
      FDataBand.Width := FPage.Width;
      FDataBand.Stretched := True;
    End;
    
    

    Hope this helps,

    Regards,

    Andy

Leave a Comment

Rich Text Editor. To edit a paragraph's style, hit tab to get to the paragraph menu. From there you will be able to pick one style. Nothing defaults to paragraph. An inline formatting menu will show up when you select text. Hit tab to get into that menu. Some elements, such as rich link embeds, images, loading indicators, and error messages may get inserted into the editor. You may navigate to these using the arrow keys inside of the editor and delete them with the delete or backspace key.