C# 打印 Winform/视觉元素
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/5307/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Print a Winform/visual element
提问by Tarks
All the articles I've found via google are either obsolete or contradict one another.
我通过谷歌找到的所有文章要么已经过时,要么相互矛盾。
What's the easiest way to print a form or, say, a richtextbox in c#? I think it's using the PrintDiaglog
class by setting the Document
, but how does this get converted?
在 C# 中打印表单或富文本框的最简单方法是什么?我认为它是PrintDiaglog
通过设置来使用类Document
,但是这是如何转换的?
采纳答案by Vaibhav
At least in VS 2008, its very easy. It took me about a couple of minutes to code the answer after reading your question. Here's where I borrowed it from:
至少在 VS 2008 中,它非常容易。阅读您的问题后,我花了大约几分钟来编写答案。这是我从那里借来的:
http://msdn.microsoft.com/en-us/library/6he9hz8c.aspx
http://msdn.microsoft.com/en-us/library/6he9hz8c.aspx
I tested this, and it works.
我测试了这个,它有效。
回答by OwenP
Someone I know created a component that extends controls with a lot of properties that give you a lot of control over how the form prints. It's worth a look.
我认识的某个人创建了一个组件,该组件扩展了具有许多属性的控件,这些属性使您可以对表单的打印方式进行大量控制。值得一看。