Problem building bands on runtime

edited February 2009 in FastReport 4.0
I have a problem. I'm trying to create a report only using code at runtime.

I'm doing this because I don't know before running how many band will i have and they are all different.

So, that's an extract of my code :
  // Rapport
  FReport := TfrxReport.Create(Application);
  FReport.Clear;
  // Page du rapport
  FPage    := TfrxReportPage.Create(FReport);
  with FPage do
  begin
    SetDefaults;
    Orientation := poLandscape;
  end;

  ////////////// Instanciation de la bande titre. /////////////////////
  lBand := TfrxPageHeader.Create(aPage);
  lBand.CreateUniqueName;
  lBand.Top := 0;
  lBand.Height := 20;

  // Barre horizontale
  lMemoHorizontalBar := TfrxMemoView.Create(lBand);
  with lMemoHorizontalBar do
  begin
    // Graphisme
    Top           := 1.40 * fr1cm;
    Left          := 0;
    Height        := 0;
    Font.Color    := clBlack;
    Font.Height   := -13;
    Font.Name     := 'Arial';
    Font.Style    := [];
    Frame.Typ     := [ftBottom];
    HAlign        := haRight;
    ParentFont    := False;
    VAlign        := vaCenter;
    CreateUniqueName;
    Align := baWidth;
  end;

  // Date
  lMemoDate := TfrxMemoView.Create(lBand);
  with lMemoDate do
  begin
    CreateUniqueName;
    Text   := FDate;
    Height := 0.9 * fr1cm;
    Width  := 4.5 * fr1cm;
    left   := 10  * fr1cm;
    HAlign := haRight;
    Align  := baRight;
  end;

  // Nom
  lMemoName := TfrxMemoView.Create(lBand);
  with lMemoName do
  begin
    CreateUniqueName;
    Text   := FAuthorName;
    Height := 0.9 * fr1cm;
    Width  := 4.5 * fr1cm;
    left   := 0;
  end;

  // Titre
  lMemoTitle := TfrxMemoView.Create(lBand);
  with lMemoTitle do
  begin
    CreateUniqueName;
    Text        := FTitle;
    Height      := 0.9 * fr1cm;
    Width       := 18.50 * fr1cm;
    Align       := baCenter;
    Font.Style  := [fsBold];
    HAlign      := haCenter;    
  end;

  ////// Instanciation d'une bande de donn?©es.//////////
  lDataBand := TfrxMasterData.Create(aPage);
  lDataBand.CreateUniqueName;
  lDataband.PrintIfDetailEmpty := True;
  lDataband.DataSetName := '1';
  lDataband.RowCount := 1;
  lDataband.Top := 0;

  // Ajout d'un memo dans le DataBand;
    // Titre
  lMemo := TfrxMemoView.Create(lDataBand);
  with lMemo do
  begin
    CreateUniqueName;
    Text          := 'TOTO';
    StretchMode   := smMaxHeight;
    Align         := baWidth;
    Font.Style    := [];
    HAlign        := haLeft;
    AllowHTMLTags := true;
    WordWrap      := True;
  end;

  FReport.ShowReport;


As a result, i have the masterdata band over the header band.

My question is simple :
how can I have this bands one after the other ?

Thanks for the answer.

Comments

  • edited 5:19AM
    Perhaps its the TOP porperty.
      lBand := TfrxPageHeader.Create(aPage);
      lBand.CreateUniqueName;
      lBand.Top := 0;
    
    
      lDataBand := TfrxMasterData.Create(aPage);
      lDataBand.CreateUniqueName;
      lDataband.Top := 1;
    

    on your code, I see they are both set to 0
  • edited 5:19AM
    Selmeyer wrote: »
    Perhaps its the TOP porperty.
      lBand := TfrxPageHeader.Create(aPage);
      lBand.CreateUniqueName;
      lBand.Top := 0;
    
    
      lDataBand := TfrxMasterData.Create(aPage);
      lDataBand.CreateUniqueName;
      lDataband.Top := 1;
    

    on your code, I see they are both set to 0

    I have just tried this... It didn't work. Maybe I'm missing something on page or report parameters ??? I don't understand why the bands are not the one after each other. If i put lDataband.Top := 15 * fr1cm for example, the databand is still stucked at the top of the page.

    Please help !
  • edited 5:19AM
    Yes !!! I did it !!!

    The solution :
    It's very important to put the param Streched := True for each band. Great.

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.