Hallo,
vielen Dank, wenn man weiß wie es geht ist es wirklich ganz einfach.
Delphi-Quellcode:
procedure GridPreview(Grid: TDBGrid);
var
page_wide : Integer;
page: TfrxReportPage;
band: TfrxBand;
memo: TfrxMemoView;
// cross: TfrxCrossView;
masterBand: TfrxMasterData;
i, x: Integer;
CurrentLeft, CurrentTop : integer;
BMark: TBookmark;
Procedure AddPage();
begin
// Add a page
page:= TfrxReportPage.Create(GridRep);
page.CreateUniqueName;
page.SetDefaults;
page.Orientation:= poLandscape;
// Add a report title band
band:= TfrxReportTitle.Create(page);
band.CreateUniqueName;
band.Top:= 0;
band.Height:= Abs(Grid.Font.Height) + 10;
// Add object to the report title band
memo:= TfrxMemoView.Create(band);
memo.CreateUniqueName;
memo.Text:= 'Test';
memo.Height:= Abs(Grid.Font.Height) + 10;
memo.Align := baWidth;
// Add masterdata band
masterBand:= TfrxMasterData.Create(page);
masterBand.CreateUniqueName;
masterBand.DataSet:= dataset;
masterBand.Top:= band.Top+band.Height+1;
masterBand.Height:= (Canvas.TextHeight('A') + 10);
end ;
begin
// Make sure that report is clean.
GridRep.Clear;
// Set dataset range properties
dataset.RangeEnd:= reCount;
dataset.RangeEndCount:= grid.DataSource.DataSet.RecordCount;
// Add dataset to report
GridRep.DataSets.Add(dataset);
AddPage;
// Add objects on master data
x:= 0;
page_wide :=0;
for I := 0 to Grid.Columns.Count - 1 do
begin
// ShowMessage(IntToStr(i)+'___'+Grid.Columns.Items[I].Field.FieldName);
if (Grid.Columns.Items[I].Visible) then
begin
if (page_wide+ Grid.Columns[I].Width+5) > page.Width then
begin
AddPage;
page_wide :=0;
x:= 0;
end;
memo:= TfrxMemoView.Create(masterBand);
memo.CreateUniqueName;
// Connect to data
memo.DataSet:= dataset;
memo.DataField:= Grid.Columns.Items[I].FieldName;
memo.SetBounds(x, 0, Grid.Columns[I].Width, (Canvas.TextHeight('A') + 10));
x:= x+grid.Columns[I].Width;
memo.Frame.Typ:= [ftLeft, ftRight, ftTop, ftBottom];
// Aufsummieren der Columsbreiten
page_wide := page_wide + ROUND(memo.Width);
memo.GapX:= 3;
memo.GapY:= 2;
end;
end;
GridRep.Showreport;
end;
@ich fange an, an Fastreport gefallen zu finden.