📄 rm_pdbgrid.pas
字号:
liView := TRMMemoView(FFormReport.Report.FindObject(FList[i]));
if liView <> nil then
begin
liView.spHeight := liHeight;
s := THackGrid(FGrid).GetEditText(i, FCurrentRow);
if s = '[Error]' then
s := '';
liView.Memo.Text := s;
end;
if FCurrentRow < 0 then //Fixed Row
begin
end
else
begin
end;
end;
end;
procedure TRMFormPrintStringGrid.OnUserDatasetCheckEOF(Sender: TObject; var Eof: Boolean);
begin
Eof := FCurrentRow > (THackGrid(FGrid).RowCount - 1);
end;
procedure TRMFormPrintStringGrid.OnUserDatasetFirst(Sender: TObject);
begin
FCurrentRow := THackGrid(FGrid).FixedRows;
SetMemos;
end;
procedure TRMFormPrintStringGrid.OnUserDatasetNext(Sender: TObject);
begin
Inc(FCurrentRow);
SetMemos;
end;
procedure TRMFormPrintStringGrid.OnUserDatasetPrior(Sender: TObject);
begin
Dec(FCurrentRow);
SetMemos;
end;
procedure TRMFormPrintStringGrid.OnReportBeginBand(Band: TRMBand);
begin
if Band.BandType = rmbtMasterData then // .Name = FFormReport.DetailBandName then
Band.spHeight := THackGrid(FGrid).RowHeights[FCurrentRow];
end;
procedure TRMFormPrintStringGrid.OnGenerate_Object(aFormReport: TRMFormReport;
aPage: TRMReportPage; aControl: TControl; var t: TRMView);
var
liView: TRMMemoView;
i, j, liPageNo, Leftx, NextLeft, lNextTop: Integer;
liNum: Integer;
liGrid: THackGrid;
s: string;
liGridTitleHeight: Integer;
liFlagFirstColumn: Boolean;
liPage: TRMReportPage;
procedure _DrawDoubleFrameBottom(aView: TRMView; aList: TList);
var
t: TRMMemoView;
begin
if rmgoDoubleFrame in aFormReport.ReportOptions then
begin
t := TRMMemoView(RMCreateObject(rmgtMemo, ''));
t.ParentPage := liPage;
t.LeftFrame.Visible := False;
t.TopFrame.Visible := True;
t.RightFrame.Visible := False;
t.BottomFrame.Visible := False;
t.TopFrame.Width := 2;
t.GapLeft := 0;
t.GapTop := 0;
t.SetspBounds(aView.spLeft, aFormReport.GridTop + aFormReport.GridHeight, aView.spWidth, 2);
TRMMemoView(t).Stretched := rmgoStretch in aFormReport.ReportOptions;
aList.Add(t);
end;
end;
procedure _MakeOneHeader(aRow, aIndex: Integer);
begin
liView := TRMMemoView(RMCreateObject(rmgtMemo, ''));
liView.ParentPage := liPage;
TRMMemoView(liView).VAlign := rmvCenter;
TRMMemoView(liView).HALign := rmhCenter;
TRMMemoView(liView).Stretched := rmgoStretch in aFormReport.ReportOptions;
TRMMemoView(liView).WordWrap := rmgoWordWrap in aFormReport.ReportOptions;
liView.spLeft := NextLeft;
liView.spTop := lNextTop;
liView.spWidth := liGrid.ColWidths[aIndex] + 1;
liView.spHeight := liGrid.RowHeights[aRow] + 4;
liView.Font.Assign(liGrid.Font);
s := liGrid.GetEditText(aIndex, aRow);
if s = '[Error]' then
s := '';
liView.Memo.Text := s;
if rmgoGridLines in aFormReport.ReportOptions then
begin
liView.LeftFrame.Visible := True;
liView.TopFrame.Visible := True;
liView.RightFrame.Visible := True;
liView.BottomFrame.Visible := True;
end
else
begin
liView.LeftFrame.Visible := False;
liView.TopFrame.Visible := False;
liView.RightFrame.Visible := False;
liView.BottomFrame.Visible := False;
end;
aFormReport.ColumnHeaderViews.Add(liView);
NextLeft := NextLeft + liView.spWidth;
if rmgoDoubleFrame in aFormReport.ReportOptions then
begin
if liFlagFirstColumn then
liView.LeftFrame.Width := 2;
liView.TopFrame.Width := 2;
end;
liFlagFirstColumn := False;
end;
procedure _MakeOneDetail(aIndex: Integer);
begin
liView := TRMMemoView(RMCreateObject(rmgtMemo, ''));
liView.ParentPage := liPage;
liView.VAlign := rmvCenter;
liView.HAlign := rmhCenter;
TRMMemoView(liView).Stretched := rmgoStretch in aFormReport.ReportOptions;
TRMMemoView(liView).WordWrap := rmgoWordWrap in aFormReport.ReportOptions;
liView.Font.Assign(liGrid.Font);
if rmgoGridLines in aFormReport.ReportOptions then
begin
liView.LeftFrame.Visible := True;
liView.TopFrame.Visible := True;
liView.RightFrame.Visible := True;
liView.BottomFrame.Visible := True;
end
else
begin
liView.LeftFrame.Visible := False;
liView.TopFrame.Visible := False;
liView.RightFrame.Visible := False;
liView.BottomFrame.Visible := False;
end;
liView.spLeft := NextLeft;
liView.spWidth := liGrid.ColWidths[aIndex] + 1;
liView.spTop := 0;
liView.spHeight := 4;
aFormReport.PageDetailViews.Add(liView);
FList.Add(liView.Name);
NextLeft := NextLeft + liView.spWidth;
if rmgoDoubleFrame in aFormReport.ReportOptions then
begin
if liFlagFirstColumn then
liView.LeftFrame.Width := 2;
end;
_DrawDoubleFrameBottom(liView, aFormReport.ColumnFooterViews);
liFlagFirstColumn := False;
end;
procedure _DrawFixedHeader(aRow: Integer);
var
j: Integer;
begin
for j := 0 to aFormReport.GridFixedCols - 1 do
begin
if j < liGrid.ColCount then
_MakeOneHeader(aRow, j);
end;
end;
procedure _DrawFixedDetail;
var
i: Integer;
begin
for i := 0 to aFormReport.GridFixedCols - 1 do
begin
if i < liGrid.ColCount then
_MakeOneDetail(i);
end;
end;
begin
// if aFormReport.DrawOnPageFooter then Exit;
liGrid := THackGrid(aControl);
FGrid := TCustomGrid(aControl);
FFormReport := aFormReport;
aFormReport.DrawOnPageFooter := True;
aFormReport.GridTop := THackFormReport(aFormReport).OffsY + aControl.Top;
aFormReport.GridHeight := aControl.Height;
liGridTitleHeight := 0;
lNextTop := aControl.Top + THackFormReport(aFormReport).OffsY;
if FUserDataset = nil then
FUserDataset := TRMUserDataset.Create(nil);
if FList = nil then
FList := TStringList.Create;
THackFormReport(aFormReport).CanSetDataSet := False;
FList.Clear;
FUserDataset.OnCheckEOF := OnUserDatasetCheckEOF;
FUserDataset.OnFirst := OnUserDatasetFirst;
FUserDataset.OnNext := OnUserDatasetNext;
FUserDataset.OnPrior := OnUserDatasetPrior;
aFormReport.Report.DataSet := FUserDataset;
aFormReport.Report.OnBeginBand := OnReportBeginBand;
Leftx := 0;
for i := 0 to liGrid.ColCount - 1 do
Leftx := Leftx + liGrid.ColWidths[i] + 1;
if (aFormReport.PrintControl = aControl) or (Leftx > StrToInt(THackFormReport(aFormReport).FormWidth[0])) then
THackFormReport(aFormReport).FormWidth[0] := IntToStr(Leftx + (THackFormReport(aFormReport).OffsX + aControl.Left) * 2);
Leftx := aControl.Left + THackFormReport(aFormReport).OffsX;
NextLeft := 0;
if liGrid.FixedRows > 0 then //表头
begin
liFlagFirstColumn := True;
for i := 0 to liGrid.FixedRows - 1 do
begin
liGridTitleHeight := liGridTitleHeight + liGrid.RowHeights[i] + 4;
NextLeft := Leftx;
liPageNo := 0;
liNum := 0;
liPage := TRMReportPage(aFormReport.Report.Pages[0]);
for j := 0 to liGrid.ColCount - 1 do
begin
if (aFormReport.ScaleMode.ScaleMode <> rmsmFit) or (not aFormReport.ScaleMode.FitPageWidth) then
begin
if (liNum > 0) and (THackFormReport(aFormReport).CalcWidth(NextLeft + (liGrid.ColWidths[j] + 1)) > THackFormReport(aFormReport).PageWidth) then // 超宽
begin
liFlagFirstColumn := True;
if rmgoDoubleFrame in aFormReport.ReportOptions then
liView.RightFrame.Width := 2;
THackFormReport(aFormReport).FormWidth[liPageNo] := IntToStr(NextLeft);
liNum := 0;
Inc(liPageNo);
if liPageNo >= aFormReport.Report.Pages.Count then
begin
THackFormReport(aFormReport).AddPage;
THackFormReport(aFormReport).FormWidth.Add('0');
end;
liPage := TRMReportPage(aFormReport.Report.Pages[liPageNo]);
NextLeft := Leftx;
liFlagFirstColumn := True;
_DrawFixedHeader(i);
end;
end;
_MakeOneHeader(i, j);
Inc(liNum);
end;
lNextTop := lNextTop + liGrid.RowHeights[i] + 4;
end;
liFlagFirstColumn := True;
if rmgoDoubleFrame in aFormReport.ReportOptions then
liView.RightFrame.Width := 2;
end;
if THackFormReport(aFormReport).FormWidth.Count > 1 then
THackFormReport(aFormReport).FormWidth[THackFormReport(aFormReport).FormWidth.Count - 1] := IntToStr(NextLeft);
liPage := aPage;
liPageNo := 0;
liNum := 0;
NextLeft := aControl.Left + THackFormReport(aFormReport).OffsX;
liFlagFirstColumn := True;
for i := 0 to liGrid.ColCount - 1 do //表体
begin
if (aFormReport.ScaleMode.ScaleMode <> rmsmFit) or (not aFormReport.ScaleMode.FitPageWidth) then
begin
if (liNum > 0) and (THackFormReport(aFormReport).CalcWidth(NextLeft + (liGrid.ColWidths[i] + 1)) > THackFormReport(aFormReport).PageWidth) then // 超宽
begin
liFlagFirstColumn := True;
if rmgoDoubleFrame in aFormReport.ReportOptions then
liView.RightFrame.Width := 2;
THackFormReport(aFormReport).FormWidth[liPageNo] := IntToStr(NextLeft);
Inc(liPageNo);
liNum := 0;
if liPageNo >= aFormReport.Report.Pages.Count then
begin
THackFormReport(aFormReport).AddPage;
THackFormReport(aFormReport).FormWidth.Add('0');
end;
liPage := TRMReportPage(aFormReport.Report.Pages[liPageNo]);
NextLeft := aControl.Left + THackFormReport(aFormReport).OffsX;
liFlagFirstColumn := True;
_DrawFixedDetail;
end;
end;
_MakeOneDetail(i);
Inc(liNum);
end;
if liNum > 0 then
begin
liFlagFirstColumn := True;
if rmgoDoubleFrame in aFormReport.ReportOptions then
liView.RightFrame.Width := 2;
end;
if THackFormReport(aFormReport).FormWidth.Count > 1 then
THackFormReport(aFormReport).FormWidth[THackFormReport(aFormReport).FormWidth.Count - 1] := IntToStr(NextLeft);
end;
initialization
RMRegisterFormReportControl(TStringGrid, TRMFormPrintStringGrid);
RMRegisterFormReportControl(TCustomDBGrid, TRMFormPrintDBGrid);
end.
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -