Hi community
I'm developing a report in LazReport in which I would like to dynamically create groupings at runtime so that the user can select which fields and in what order he wants to do the groupings.
I'm trying to do it like this:
In a ready-made report I'm trying to create a band of type Group Header and a Memo to show the grouping field. I'm implementing this in a button.
The memo is returning the value correctly, however I am not able to get the band to be created or to work correctly.
Here's my code below:
procedure TfrmRelatorios.Button1Click(Sender: TObject);
var
Band: TfrBand;
Memo: TfrMemoView;
begin
try
frReport1.LoadFromFile(Application.Location + 'Reports\RelEntregas.lrf');
Band := TfrBand.Create(btGroupHeader, frReport1.Pages.Pages[0]);
Band.CreateUniqueName;
Band.DataSet := frReport1.Dataset;
Band.GroupCondition := 'sqlqRelatorio."EMPRESA"';
Band.Top := 89;
Band.Left := 0;
Band.Height := 22;
Band.Width := 752;
Band.Visible := True;
Memo := TfrMemoView.Create(frReport1.Pages.Pages[0]);
Memo.Parent := Band;
Memo.ParentBandType := btMasterData;
Memo.CreateUniqueName;
Memo.Memo.Add('[sqlqRelatorio."EMPRESA"]');
Memo.Top := Band.Top+2;
Memo.Height := 18;
Memo.Width := 200;
Memo.Left := 20;
Memo.Font.Size := 9;
Memo.Font.Style := [fsBold];
frReport1.ShowReport;
except on E: exception do
begin
Application.MessageBox(PChar('Erro ao tentar gerar o relatório'+#13#13
+'Classe '+E.ClassName+#13
+'Detalhes: '+E.Message)
,'Erro',MB_ICONERROR + MB_OK);
Abort;
end;
end;
end;
PS. It's not generating any error, however the band isn't being created or something is missing to create the groups in the report.
PS2. Let me know if there's an easier way to do what I'm looking for.
A hug Lazarus community