如何打印Windows窗体和appearabe datagridview [英] how to print a windows form and a appearabe datagridview

查看:104
本文介绍了如何打印Windows窗体和appearabe datagridview的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

朋友们,

我有一个带有一些标签的windows窗体和一个带有自动可吸引滚动条的datagridview(实际上很多关于datagridview的信息,直到用户向下滚动才会在datagrid视图中显示)。我的问题是,我想在第一页中打印一些windows格式的所有信息,在第2页或第3页打印其他行的datagridview和windows窗体控件(上面有一些标签)。我必须做什么?

谢谢。

解决方案

即使在CodeProject上,你也可以找到很多相关的代码:

http:// www .codeproject.com / search.aspx?q = print + form +%22C%23%22& doctypeid = 1& sort = createddesc [ ^ ],

< a href =http://www.codeproject.com/search.aspx?q=print+DataGridView+%22C%23%22&doctypeid=1> http://www.codeproject.com/search.aspx?q = print + DataGridView +%22C%23%22& doctypeid = 1 [ ^ ]。



特别是:

以报告方式打印表单(2.2版) [ ^ ],

表格打印控制 [ ^ ],

打印任何控件的组件,包括ListViews,TreeViews,DataGridViews和Forms [ ^ ],

用C#简化.NET打印 [ ^ ],

打印DataGridView [ ^ ],

使用API​​打印Windows窗体 [ ^ ],

FormPrint作为一个简单的类 [ ^ ] 。



但是,在许多情况下,打印数据可能是一个好主意,而不是表格。您可以打印数据源中的数据,用于填充UI或绑定到的数据,而不是UI本身。所有你需要知道的是类 System.Drawing.Printing.PrintDocument

http://msdn.microsoft.com/en-us/library/system.drawing.printing.printdocument.aspx [< a href =http://msdn.microsoft.com/en-us/library/system.drawing.printing.printdocument.aspxtarget =_ blanktitle =New Window> ^ ]。



您可以在本MSDN文章末尾找到有用的代码示例。



- SA

hi friends,
i have a windows form with some labels and a datagridview with automatic appearaable scrollbar(in fact many information on datagridview that does not shown in datagrid view until user scroll down). my problem is this that i want to print all information of windows form with some rows of datagridview in first page and other rows of datagridview with windows form controls(some labels on it) in page 2 or 3 or ... . what i must do?
thank you.

解决方案

Even on CodeProject along, you can find a lot of relevant code:
http://www.codeproject.com/search.aspx?q=print+form+%22C%23%22&doctypeid=1&sort=createddesc[^],
http://www.codeproject.com/search.aspx?q=print+DataGridView+%22C%23%22&doctypeid=1[^].

In particular:
Printing a Form in a report fashion (release 2.2)[^],
Form Print Control[^],
A component that prints any control, including ListViews, TreeViews, DataGridViews, and Forms[^],
Simplified .NET Printing in C#[^],
Printing of DataGridView[^],
Print Windows Forms w/o using API[^],
FormPrint as a simple class[^].

However, for many cases, it's probably a good idea to print data, not a form. You can print the data from your data source, the same data you used to populate your UI or bind to it, not the UI itself. All you need to know is the class System.Drawing.Printing.PrintDocument:
http://msdn.microsoft.com/en-us/library/system.drawing.printing.printdocument.aspx[^].

You can find a useful code sample at the end of this MSDN article.

—SA


这篇关于如何打印Windows窗体和appearabe datagridview的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆