01]假设我们要打印dxBarCode1,先拖一个dxBarCode1,并设定其text
02]拖一个dxComponentPrinter1,并双击它,点Add...增加 打印链接。
03]打印预览
//dxComponentPrinter1.Preview(True,dxComponentPrinter1Link1); dxComponentPrinter1Link1.Preview(True);
03]打印
dxComponentPrinter1.Print(True,nil,dxComponentPrinter1Link1);
04]类似地,双击它dxComponentPrinter1,并,点Add...增加 打印链接dxComponentPrinter1Link2 ,为Memo1设置打印预览和打印功能。
dxComponentPrinter1.Preview(True,dxComponentPrinter1Link2);
05]打印页面设置
这些设置可以保存到文件,以便下次再使用“。要分开来
,保存 和 读取 设置。
procedure TForm13.Button4Click(Sender: TObject); begin dxComponentPrinter1Link1.PrinterPage.SaveToFile('d:\aa.ini'); end; procedure TForm13.Button5Click(Sender: TObject); begin dxComponentPrinter1Link1.PrinterPage.LoadFromFile('d:\aa.ini'); end;
也可以直接代码设置
var begintime, endtime: string; begin begintime := FormatDateTime('yyyy-MM-dd 00:00:00', dtp_begin.DateTime); endtime := FormatDateTime('yyyy-MM-dd 23:59:59', dtp_end.DateTime); dxComponentPrinter1Link1.ReportTitle.Text := '日期:' + begintime + '至' + endtime; dxComponentPrinter1Link1.ReportTitle.Font.Size := 10; dxComponentPrinter1Link1.ReportTitle.Font.Name := '宋体'; dxComponentPrinter1Link1.PrinterPage.pageheader.CenterTitle.Text := '科室收入统计'; dxComponentPrinter1Link1.PrinterPage.pageheader.Font.Size := 14; dxComponentPrinter1Link1.PrinterPage.pageheader.Font.Name := '宋体';
end;