这个示例展示了如何使用 ReportPrintTool 打印报表 (通过 PrintTool.Print 和 PrintTool.PrintDialog 方法)。
要使本示例正确工作,则派生于 XtraReport 类的 XtraReport1 类应该在示例应用程序中存在。
C# | 复制代码 |
---|---|
using System; using System.Windows.Forms; using DevExpress.XtraReports.UI; // ... private void button1_Click(object sender, EventArgs e) { // Create a report instance, assigned to a Print Tool. ReportPrintTool pt = new ReportPrintTool(new XtraReport1()); // Invoke the Print dialog. pt.PrintDialog(); // Send the report to the default printer. pt.Print(); // Send the report to the specified printer. pt.Print("myPrinter"); } |
Visual Basic | 复制代码 |
---|---|
Imports System Imports System.Windows.Forms Imports DevExpress.XtraReports.UI ' ... Private Sub button1_Click(ByVal sender As Object, _ ByVal e As EventArgs) Handles button1.Click ' Create a report instance, assigned to a Print Tool. Dim pt As New ReportPrintTool(New XtraReport1()) ' Invoke the Print dialog. pt.PrintDialog() ' Send the report to the default printer. pt.Print() ' Send the report to the specified printer. pt.Print("myPrinter") End Sub |
Show Me |
---|
在 DevExpress Code Central 数据库中可以找到完整的示例项目,网址是 http://www.devexpress.com/example=E138。 取决于目标平台类型 (ASP.NET、WinForms 等),可以在线运行本示例,或者下载自动可执行的示例。 |