- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我正在尝试从 datagridview 打印选定的文件。此文件位置保存在数据库中。现在在打印之前我想将“份数,从页面到页面”传递给 PrintDialog。我能够将这些值传递给 PrintDialog,但它不起作用,所有页面都在打印,而且也只打印一次。我什至在网上搜索了很多,但无法解决这个问题。
请通过选择所有页面选项或将值传递给 FromPage 和 ToPage 来帮助我打印“n”份。我的代码是:
//string ASSIGNMENT_PATH = dataGridView1.Rows[k].Cells[2].Value.ToString();
string ASSIGNMENT_PATH = "@C:\test.docx";
if (!File.Exists(ASSIGNMENT_PATH))
{
MessageBox.Show("No exceptional file created by application till now .");
}
else
{
short noC = Convert.ToInt16(txtNumOfCopies.Text);
short fP = Convert.ToInt16(txtFromPage.Text);
short tP = Convert.ToInt16(txtToPage.Text);
PrintDialog dialog = new PrintDialog();
dialog.AllowSomePages = true;
dialog.PrinterSettings.FromPage = fP;
dialog.PrinterSettings.ToPage = tP;
dialog.PrinterSettings.Copies = noC;
DialogResult dialogResult = dialog.ShowDialog(this);
if (dialogResult == DialogResult.Cancel)
{
this.Close();
}
if (dialogResult == DialogResult.OK)
{
ProcessStartInfo info = new ProcessStartInfo(ASSIGNMENT_PATH);
info.Verb = "PrintTo";
info.Arguments = "\"" + printDialog1.PrinterSettings.PrinterName + "\"";
info.CreateNoWindow = true;
info.WindowStyle = ProcessWindowStyle.Hidden;
Process.Start(info);
}
}
最佳答案
在此代码中,您使用了 2 种打印方法。
第一种方法,使用 PrintDialog,它不适用于您的情况,因为您必须设置 Document 属性。
第二种方法,使用 Process 类并打印所有页面,因为您在参数处将整个文件发送到打印机。
它是打印 DataGridView 的示例 http://www.codeproject.com/Articles/28046/Printing-of-DataGridView或者你也可以试试这个 How to print values from a DataGridView control
关于c# - PrintDialog.PrinterSettings 不工作,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19313868/
我有一个 System.Window.Controls.PrintDialog 并且我想使用单个 PrintTicket 以横向模式和纵向模式打印页面,但似乎我只能设置一次方向。 只要我想在纸上打印,
我有这个程序,我可以在其中打印一些关于托盘(物流)的信息,我需要向其中添加条形码。我环顾四周,发现 http://www.codeproject.com/Articles/20823/Barcode-
在 C# Winform 中,我使用 PrintDialog 将图像发送到打印机...使用此代码: private void PrintSnippedImage() {
只是想知道是否有一种方法可以在使用流文档的打印对话框上设置打印文档方向。 例如 var document = userControl.Content as FlowDocument; var prin
我正在尝试从 datagridview 打印选定的文件。此文件位置保存在数据库中。现在在打印之前我想将“份数,从页面到页面”传递给 PrintDialog。我能够将这些值传递给 PrintDialog
好的,在我的程序中,我显示了一个 printDialog,我希望能够知道用户是单击了打印按钮还是取消按钮。在我看到的所有在线示例中,printDialogs 都有 OK 按钮,而不是 Print 按钮
我打开一个 PrintDialog 框,然后使用它设置打印信息; DialogResult result = PrintDialog.ShowDialog(); 现在,我想在单击“应用”按钮时保存
我的 C# 程序允许用户选择他们希望将一些标签打印到几台名称相似的打印机中的哪一台。与它必须显示的打印机名称相比,标准 PrintDialog 相当狭窄,因此您无法在下拉列表中看到所有打印机的完整名称
我有一份报告,想打印它。目前我正在使用: myreport.PrintDialog() 如果我在 Windows PrintDialog 上单击“中止”,报告将在标准打印机上打印。我该如何处理这个中止
我已广泛搜索此问题的解决方案,但未能找到可用于我当前代码的任何内容。 我有一个表单应用程序,它对 SQL Server 表执行查询并用行填充 dataGridView。然后我有一个按钮将 dataGr
我在 .net 2.0 上有一个 Windows 应用程序。在 Form1 上,我打开了一个 PrintDialog。如何从我的代码中获取该对话框的句柄? 我已经尝试了很多 win32 函数:Enum
我正在尝试从代码打印到网络打印机,但打印对话框中的网络打印机状态显示访问被拒绝,无法连接并且打印按钮被禁用。但是如果我从另一个应用程序打印,我可以很好地打印到那台打印机。而且,如果我从打印对话框中选择
嘿我正在寻找一种方法来绕过 IE 9 中的 printdialog。我现在有一些方法适用于 ie 7/8,但它们在 ie9 上对我不起作用 有人可以给我提示吗? 问候马库斯 最佳答案 这里成功的关键组
我有一个对话框,该对话框内有一个表格查看器,用于显示用户操作的结果。我创建了一个带有打印按钮的方法。打印代码包括我从示例中找到的示例代码。 final Text t = new Text(compos
在向用户显示对话框后,我试图修改从 System.Windows.Forms.PrintDialog 获得的 System.Drawing.Printing.PrinterSettings 对象。尽管
这段代码在 .Net 中为任何 CPU 平台构建并在 64 位机器上运行时,只返回一个 Cancel 的 DialogResult 而不显示预期的对话框。 Dim dlg As New System.
我想用 PrintDocument 打印一个非常简单的布局适合一页,所以不需要 DocumentPaginator .但是我想使用 PrinterDialog选择打印机。我看到了 PrinterSet
我想检查我的默认打印机是否打开,如果没有打开,我想选择另一台打印机。我使用下面的代码来检查它是否打开,但它总是返回 true。任何帮助将不胜感激 bool printerIsOnline = fals
我正在创建一个 Java 应用程序,应用程序将在其中打印图片和旁边的一些文本。我在打印时有两台打印机,我会相应地选择。我不会显示打印对话框供用户选择打印机和其他东西。我的代码如下 PrinterJob
这可能吗? 我正在获取现有 PDF 文档的目录和文件名。 C:\temp\FileName.pdf 使用 PDF 渲染器查看文档或打印文档我的 Eclipse 项目中包含 PDF 渲染器,只是不知道如
我是一名优秀的程序员,十分优秀!