📄 u_form1.~pas
字号:
unit U_Form1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, Grids, DBGrids, DB, DBTables, RpDefine, RpBase, RpSystem,
StdCtrls, ComCtrls;
type
TForm1 = class(TForm)
Table1: TTable;
DataSource1: TDataSource;
DBGrid1: TDBGrid;
RvSystem1: TRvSystem;
PrintButton: TButton;
procedure RvSystem1Print(Sender: TObject);
procedure PrintButtonClick(Sender: TObject);
procedure FormCreate(Sender: TObject);
private
{ Private declarations }
procedure MyPrintReport(Report:TBaseReport);
public
PreLeft:double;
ZoomCoe:double;
TotalWidth:integer ; //DBGrid的宽度
UnitPointWidth:double ; //网络单位与报表单位比例系统
{ Public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
{ TForm1 }
procedure TForm1.MyPrintReport(Report: TBaseReport);
var
i,j:integer;
Bitmap : TBitmap;
begin
for i:=0 to DBGrid1.Columns.Count-1 do
begin
if DBGrid1.Columns.Items[i].Visible=false then
continue
else
TotalWidth:=TotalWidth+DBGrid1.Columns.Items[i].Width;
end;
UnitPointWidth:=8.2/TotalWidth;
ZoomCoe:=1;
PreLeft:=0.4;
Bitmap := TBitmap.Create;
Bitmap.LoadFromFile('Picture.bmp');
with Report do
begin
PrintBitmap(PreLeft,0.7, 1.1,1.5, Bitmap);
Canvas.Brush.Color :=clAqua ;
Rectangle(PreLeft, 0.5, 8.2-PreLeft, 0.68);
SetFont('黑体', 15);
FontColor := clBlue;
NewLine;
PrintCenter('足彩竞猜球队信息表', 4);
NewLine;
//打印字段标题
SetFont('宋体', 10);
Bold:=true;
SetTab(PreLeft, pjLeft,
ZoomCoe*UnitPointWidth*DBGrid1.Columns.Items[0].Width , 0, 0, 0);
PrintTab(DBGrid1.Columns[0].FieldName);
for i:=1 to DBGrid1.Columns.Count-1 do
begin
SetTab(NA, pjLeft,
ZoomCoe*UnitPointWidth*DBGrid1.Columns.Items[i].Width , 0, 0, 0);
PrintTab(DBGrid1.Columns[i].FieldName);
end;
MoveTo(PreLeft,0.5) ;
LineTo(8.2-PreLeft,0.5);
NewLine;
SetFont('宋体', 10);
Bold:=false;
with DBGrid1.DataSource.DataSet do
begin
first;
while (RecNo<20) do
begin
SetTab(PreLeft, pjLeft,
ZoomCoe*UnitPointWidth*DBGrid1.Columns.Items[0].Width , 0, 0, 0);
PrintTab(Fields[0].Value);
for i:=1 to DBGrid1.Columns.Count-1 do
begin
SetTab(NA, pjLeft,
ZoomCoe*UnitPointWidth*DBGrid1.Columns.Items[i].Width , 0, 0, 0);
if Fields[i].AsVariant<>null then
PrintTab(Fields[i].AsVariant)
else
PrintTab('__');
end;
NewLine;
Next;
end;
end;
end;
end;
procedure TForm1.RvSystem1Print(Sender: TObject);
begin
MyPrintReport(Sender as TBaseReport);
end;
procedure TForm1.PrintButtonClick(Sender: TObject);
begin
RvSystem1.Execute;
end;
procedure TForm1.FormCreate(Sender: TObject);
begin
DBGrid1.Columns.Items[0].Visible:=false;
end;
end.
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -