简体   繁体   English

在C#中打印Winform

[英]Print winform in C#

How to print a whole winform in c# 2008.? 如何在C#2008中打印整个Winform?

My form contains picturebox, 3 text boxes. 我的表单包含图片框,3个文本框。

Use the PrintForm control in the Visual Basic PowerPack. 在Visual Basic PowerPack中使用PrintForm控件。 It is available from the ToolBox in VS 2008 even in C# projects. 即使在C#项目中,也可以从VS 2008中的ToolBox中获得它。 I think it may have been added in SP1. 我认为可能已在SP1中添加了它。 More information here . 更多信息在这里

以为没有第三方库也可以做,我过去成功使用过PrintForm.Net

Use the following code. 使用以下代码。

using Microsoft.VisualBasic.PowerPacks.Printing;

private void printButton_Click(object sender, EventArgs e)
{
   printForm1.Print(this, PrintForm.PrintOption.ClientAreaOnly);
}

For PrintOptions See this link in MSDN 对于PrintOptions,请参见MSDN中的此链接。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM