打印图片框的内容
大家好,
我的 C# WinForms 应用程序中有一个图片框,大小为 800x800。我想使用以下代码打印此图片框的内容,但它根本不执行任何操作(仅显示打印对话框,当我单击对话框中的“打印”时,它也不执行任何操作。出了什么问题?
private void menuFilePrint_Click(object sender, EventArgs e)
{
printDocument.OriginAtMargins = true;
printDocument.DocumentName = "TEST IMAGE PRINTING";
printDialog.Document = printDocument;
printDialog.ShowDialog();
}
private void printDocument_PrintPage(object sender, PrintPageEventArgs e)
{
e.Graphics.DrawImage(curveBox.Image, 0, 0);
}
HI all,
I have a picture box in my C# WinForms application which is sized 800x800. I want to print the content of this picture box using the following code but it does not do anything at all (just shows the print dialog and when I click on PRINT in the dialog it doe nothing too. What's wrong?
private void menuFilePrint_Click(object sender, EventArgs e)
{
printDocument.OriginAtMargins = true;
printDocument.DocumentName = "TEST IMAGE PRINTING";
printDialog.Document = printDocument;
printDialog.ShowDialog();
}
private void printDocument_PrintPage(object sender, PrintPageEventArgs e)
{
e.Graphics.DrawImage(curveBox.Image, 0, 0);
}
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您没有指示
printDocument
打印:printDialog
用于设置打印设置。You didn't instruct the
printDocument
to print:the
printDialog
is used to set printing settings.如果没有此命令“printDocument1.Print();”什么都行不通。
Without this command "printDocument1.Print();" Nothing will work.