Creating Header groups from code runtime

I let my useres group their reports in runtime, means when they click a column header i add a Header Group to the report in the Object clicked event and call the frxPreview1.RefreshReport procedure.
The problem is while i was developing that functionality before the refresh report i called frxReport.DesignPreviewReport witch showed me the report in designer, for debuging reasons. And everything worked well, now i removed the DesignPreviewReport call and now the report gets rendered wrong.
Now the group headers are overllaping and the footer have expression fields witch are not calculated, can anyone help me please?

Here is the code i use for adding the groups (I have one group header/footer saved in report as template for all others):
Header := TfrxGroupHeader.Create
      //(TfrxGroupHeader(frxReport1.FindObject(d.Name)));
      (TfrxPage(frxReport1.FindObject('basePage')));
    Header.CreateUniqueName;
    Header.Top := TfrxBand(frxReport1.FindObject('MasterData1')).Top;
    Header.Height := TfrxGroupHeader(frxReport1.FindObject('GroupHeader1'))
      .Height;
    Header.condition := condition;

    Footer := TfrxGroupFooter.Create(TfrxPage(frxReport1.FindObject('basePage')));
    Footer.CreateUniqueName;
    Footer.Top := TfrxBand(frxReport1.FindObject('MasterData1')).Top;
    Footer.FHeader := Header;
    Footer.Height := TfrxGroupFooter(frxReport1.FindObject('GroupFooter1'))
      .Height;
    Footer.Width := TfrxGroupFooter(frxReport1.FindObject('GroupFooter1'))
      .Width;
    Footer.Left := TfrxGroupFooter(frxReport1.FindObject('GroupFooter1')).Left;
    Footer.Top := TfrxGroupFooter(frxReport1.FindObject('GroupFooter1')).Top;
    TfrxGroupFooter(frxReport1.FindObject('GroupFooter1')).Parent := Footer;

    for i := 0 to TfrxGroupFooter(frxReport1.FindObject('GroupFooter1'))
      .AllObjects.Count - 1 do
    begin
      // SysMemo := TfrxSysMemoView.Create(Footer);
      c := frxReport1.FindObject('GroupFooter1').AllObjects[i];
      if (c is TfrxSysMemoView) then
      begin
        SysMemo := TfrxSysMemoView.Create(Footer);
        SysMemo.CreateUniqueName;
        SysMemo.Text := TfrxSysMemoView©.Text;
        SysMemo.Height := TfrxSysMemoView©.Height;
        SysMemo.Width := TfrxSysMemoView©.Width;
        SysMemo.Left := TfrxSysMemoView©.Left;
        SysMemo.Top := TfrxSysMemoView©.Top;
        SysMemo.VAlign := TfrxSysMemoView©.VAlign;
        SysMemo.HAlign := TfrxSysMemoView©.HAlign;
        SysMemo.Font := TfrxSysMemoView©.Font;
      end;

     
    end;

    Memo := TfrxMemoView.Create(Header);
    Memo.Name := 'grpHeader' + IntToStr(groupList.Count + 1);
    Memo.Text := ReplaceStr(TfrxMemoView(frxReport1.FindObject('hd_' + field))
        .Memo.Text + ':  [frxDBDataset1."' + field + '"]', #$D#$A, '');
    Memo.Width := TfrxMemoView(frxReport1.FindObject('grpHeader1')).Width;
    Memo.Height := TfrxMemoView(frxReport1.FindObject('grpHeader1')).Height;
    Memo.Left := TfrxMemoView(frxReport1.FindObject('grpHeader1')).Left;
    Memo.Top := TfrxMemoView(frxReport1.FindObject('grpHeader1')).Top;
    Memo.VAlign := TfrxMemoView(frxReport1.FindObject('grpHeader1')).VAlign;
    Memo.HAlign := TfrxMemoView(frxReport1.FindObject('grpHeader1')).HAlign;
    Memo.Font := TfrxMemoView(frxReport1.FindObject('grpHeader1')).Font;

    qLIK.Open;
    qLIK.IndexFieldNames := qLIK.IndexFieldNames + ';' + field;
    qLIK.Close;
    frxReport1.DesignPreviewPage;
    frxPreview1.RefreshReport;

Comments

  • gpigpi
    edited 2:07PM
    You should set different values for band's Top property

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.