c# - 如何跳过printDocument.print()中的打印对话框,直接打印页面?

标签 c# .net winapp

当我在用 C# 编写的 Windows 应用程序中使用 MyPrintDocument.print() 时,会显示一个带有取消按钮的 Windows 处理打印例程的对话框。我不想显示此对话框,这可能吗?

如果不是,我应该使用哪种方式?我的程序使用热敏打印机。

最佳答案

哪个PrintController你在用吗?

The .NET Framework includes three print controllers that are derived from PrintController that help accomplish common tasks. The StandardPrintController prints a document to a printer. The PreviewPrintController generates a preview of what the document will look like when printed and is used by the PrintPreviewControl and PrintPreviewDialog classes. The PrintControllerWithStatusDialog provides a printing status dialog during the printing process.

听起来您正在使用 PrintControllerWithStatusDialog 打印 Controller


警告:我无法验证基本的 PrintController 是否以相同的方式运行。

根据这个MSDN Forum Posting PrintControllerWithStatusDialog 是默认值:

他建议是这样的:

MyPrintDocument.PrintController = new System.Drawing.Printing.StandardPrintController();

关于c# - 如何跳过printDocument.print()中的打印对话框,直接打印页面?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10572420/

相关文章:

C#串口接收数据事件

c# - 在使用 VS 2012 为 win 应用程序设置期间出错

.net - 如何使用计算器(桌面应用程序)附加我的 wpf 窗口?

.net - 你可以在没有办公室的情况下安装 Office 2007 PIA

.net - FileSystemWatcher 工作完成了吗?

c# - 发送邮件到数据库列表

c# - 用c++或C#实时录制声音

c# - 使用 PRISM 的 MVVM 模式上下文中的命令方法是什么?

c# - 如何使用 Visual Studio 2017 从我的 CPanel 连接 MySql 数据库

.net - WPF BooleanToVisibilityConverter 在 false 时转换为隐藏而不是折叠?