这个示例展示了如何指定被打印文档的页面范围。
要完成此任务,则把一个报表实例指派到 ReportPrintTool,并接管 PrintTool.PrintingSystem 打印工具的 PrintingSystemBase.StartPrint 事件。
C# | 复制代码 |
---|---|
using System; using System.Windows.Forms; using DevExpress.XtraPrinting; using DevExpress.XtraReports.UI; // ... private void button1_Click(object sender, EventArgs e) { ReportPrintTool pt = new ReportPrintTool(new XtraReport1()); pt.PrintingSystem.StartPrint += new PrintDocumentEventHandler(printingSystem_StartPrint); pt.Print(); } private void printingSystem_StartPrint(object sender, PrintDocumentEventArgs e) { // Set the page range. e.PrintDocument.PrinterSettings.FromPage = 1; e.PrintDocument.PrinterSettings.ToPage = 3; } |
Visual Basic | 复制代码 |
---|---|
Imports System Imports System.Windows.Forms Imports DevExpress.XtraPrinting Imports DevExpress.XtraReports.UI ' ... Private Sub button1_Click(ByVal sender As Object, _ ByVal e As EventArgs) Handles button1.Click Dim pt As New ReportPrintTool(New XtraReport1()) AddHandler pt.PrintingSystem.StartPrint, AddressOf printingSystem_StartPrint pt.Print() End Sub Private Sub printingSystem_StartPrint(ByVal sender As Object, _ ByVal e As PrintDocumentEventArgs) ' Set the page range. e.PrintDocument.PrinterSettings.FromPage = 1 e.PrintDocument.PrinterSettings.ToPage = 3 End Sub |
Show Me |
---|
在 DevExpress Code Central 数据库中可以找到完整的示例项目,网址是 http://www.devexpress.com/example=E1768。 取决于目标平台类型 (ASP.NET、WinForms 等),可以在线运行本示例,或者下载自动可执行的示例。 |