c# - 打印时增加 TextBox 数据的副本数

标签 c# winforms

我能够打印 TextBox 的内容。我现在要做的是增加打印的份数。我正在尝试使用此 document.PrinterSettings.Copies = numQuantity.Value; 执行此操作。

numQuantity   

是一个NumbericUpDown 控件

但是我得到了这个错误;

Cannot implicitly convert type 'decimal' to 'short'. An explicit conversion exists (are you missing a cast?)

我的代码:

private void document_PrintPage(object sender, PrintPageEventArgs e)
{
    e.Graphics.DrawString(txtName.Text, new Font("Arial", 20, FontStyle.Regular), Brushes.Black, 20, 20);
}

private void btnPrint_Click(object sender, EventArgs e)
{
    dialog.Document = document;

    document.PrinterSettings.Copies = numQuantity.Value;
    if (dialog.ShowDialog() == DialogResult.OK)
    {
        document.Print();
    }
}

谢谢

最佳答案

尝试

document.PrinterSettings.Copies = Convert.ToInt16(numQuantity.Value);

关于c# - 打印时增加 TextBox 数据的副本数,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35182388/

相关文章:

c# - 检查字符串是否包含字典键 ->删除键并添加值

c# - 禁用面板上的特定控件

C# Windows 应用程序突然崩溃,没有任何错误消息

c# - 将 .net 项目部署到开发服务器

c# - 通过在 c# 中使用 console.writeline 获取 byte [][] 的输出,servicestack

c# - System.Linq.Enumerable+WhereSelectArrayIterator 与 List<T> 上的 IEnumerable.Except()

c# - 组合框格式在文本框中显示选项卡,而不是在下拉列表中

vb.net - 调用 Web 服务函数从 Windows 窗体返回列表(字符串)

C# - 可移植类库 "XmlElement does not exist in the namespace System.XML"

c# - 如何将 .NET Identity 与 HiQPdf 结合使用并呈现经过身份验证的 PDF