PrintDialog.ShowDialog(this) 在 Windows 7 上立即返回 DialogResult.Cancel
我正在开发的内部应用程序在 Windows 7(64 位)PC 上表现奇怪。
如果我创建 PrintDialog 的实例,并调用它的 ShowDialog() 方法,该方法会立即返回 DialogResult.Cancel,而不显示打印机对话框窗体。
Windows 7 PC 确实安装了打印机(具有正常工作的默认打印机)。
PrintDialog printDialog = new PrintDialog();
printDialog.PrinterSettings.Copies = 2;
printDialog.AllowCurrentPage = false;
printDialog.AllowPrintToFile = false;
printDialog.AllowSelection = false;
printDialog.AllowSomePages = false;
DialogResult dialogResult = printDialog.ShowDialog(this);
if (dialogResult == DialogResult.Cancel)
return;
有任何线索为什么会发生这种情况吗?
An in house application that I'm developing is behaving strange on a Windows 7 (64 bit) PC.
If I create an instance of a PrintDialog, and call it's ShowDialog() method, the method immediately returns DialogResult.Cancel without showing the printer dialog form.
The Windows 7 PC does have printers installed (with a working default printer).
PrintDialog printDialog = new PrintDialog();
printDialog.PrinterSettings.Copies = 2;
printDialog.AllowCurrentPage = false;
printDialog.AllowPrintToFile = false;
printDialog.AllowSelection = false;
printDialog.AllowSomePages = false;
DialogResult dialogResult = printDialog.ShowDialog(this);
if (dialogResult == DialogResult.Cancel)
return;
Any clues why this is happening?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
将
printDialog.UseEXDialog
设置为true
以解决此错误。在 .Net 3.5 中,MSDN 在记录
UseEXDialog
时提到了这个潜在问题:(我的强调。)
.Net 4 和 .Net 4.5 不包括强调的位,所以也许它在这些版本中已修复。
Set
printDialog.UseEXDialog
totrue
to work around this bug.In .Net 3.5, MSDN mentions this potential problem when documenting
UseEXDialog
:(My emphasis.)
The same page for .Net 4 and .Net 4.5 don't include the emphasized bit, so perhaps it's fixed in those versions.