使用PrintDBGridEh进行打印 (转)
if not ADOQuery1.Active then exit;
if ADOQuery1.RecordCount<=0 then exit;
PrintDBGridEh1.PageHeader.CenterText.Clear;
PrintDBGridEh1.PageHeader.CenterText.Add(trim(edTiTle1.Text));
PrintDBGridEh1.PageHeader.CenterText.Add('');
PrintDBGridEh1.PageHeader.CenterText.Add(trim(edTiTle2.Text));
PrintDBGridEh1.PageHeader.CenterText.Add('');
PrintDBGridEh1.PageHeader.CenterText.Add('数据日期:' + datetimetostr(DateTimePicker1.DateTime
+ DateTimePicker3.DateTime - 1) + ' 至 '
+ datetimetostr(DateTimePicker2.DateTime + DateTimePicker4.DateTime - 1));
PrintDBGridEh1.PageFooter.CenterText.Clear;
PrintDBGridEh1.PageFooter.CenterText.Add
('负责人: 制表人:'+OpName+' 制表日期:'+DatetimeTostr(Date)+' 第&[Page]页' ); //第&[Page]页 共&[Pages]
if (Sender as TSpeedButton).Caption = '打印(&P)' then
PrintDBGridEh1.Print
else
PrintDBGridEh1.Preview;