How to show print dialog in Crystal Report?(如何在 Crystal Report 中显示打印对话框?)
问题描述
我想将我的 Crystal 报告
直接打印到打印机.目前我正在导出到 PDF
.但我的客户希望它直接进入打印机.如何在单击打印按钮时显示 Print Dialog
以将报告直接打印到打印机.
I want to print my Crystal report
direct to the printer. Currently I am having the export to PDF
. But my client want this to go to Printer directly. How can I show the Print Dialog
on click of Print Button to Print the report directly to Printer.
我想提一下:我正在为我的项目使用 C# 和 asp.net.
I would like to mention: I am using C# and asp.net for my project.
谢谢.
推荐答案
试试下面的代码
private void Button1_Click(object sender, EventArgs e)
{
CrystalReport1 report1 = new CrystalReport1();
PrintDialog dialog1 = new PrintDialog();
report1.SetDatabaseLogon("username", "password");
dialog1.AllowSomePages = true;
dialog1.AllowPrintToFile = false;
if (dialog1.ShowDialog() == System.Windows.Forms.DialogResult.OK)
{
int copies = dialog1.PrinterSettings.Copies;
int fromPage = dialog1.PrinterSettings.FromPage;
int toPage = dialog1.PrinterSettings.ToPage;
bool collate = dialog1.PrinterSettings.Collate;
report1.PrintOptions.PrinterName = dialog1.PrinterSettings.PrinterName;
report1.PrintToPrinter(copies, collate, fromPage, toPage);
}
report1.Dispose();
dialog1.Dispose();
}
您必须使用数据库的凭据更改用户名"和密码".
you will have to change the "username" and the "password" with the credentials of your database.
编辑
此代码仅可用于服务器端打印.
这篇关于如何在 Crystal Report 中显示打印对话框?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:如何在 Crystal Report 中显示打印对话框?


基础教程推荐
- 如何激活MC67中的红灯 2022-01-01
- c# Math.Sqrt 实现 2022-01-01
- 将 XML 转换为通用列表 2022-01-01
- 如何在 IDE 中获取 Xamarin Studio C# 输出? 2022-01-01
- SSE 浮点算术是否可重现? 2022-01-01
- 有没有办法忽略 2GB 文件上传的 maxRequestLength 限制? 2022-01-01
- rabbitmq 的 REST API 2022-01-01
- 将 Office 安装到 Windows 容器 (servercore:ltsc2019) 失败,错误代码为 17002 2022-01-01
- 为什么Flurl.Http DownloadFileAsync/Http客户端GetAsync需要 2022-09-30
- MS Visual Studio .NET 的替代品 2022-01-01