如何打印dataGridview控件? [英] How to print a dataGridview control?

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

问题描述

在我的Windows应用程序中,我想打印dataGridview控件的数据。我不知道我要编写什么代码请提供一些代码。

解决方案

关于CP的文章很多;这里只是几个:

打印DataGridView [ ^ ]

< a href =http://www.codeproject.com/Articles/16670/DataGridView-Printing-by-Selecting-Columns-and-Row>通过选择列和行进行DataGridView打印 [ ^ ]

DataGridView打印/打印预览解决方案 - 第一部分 [ ^ ]

DataGr idView打印/打印预览解决方案 - 第二部分 [ ^ ]

Another DataGridView打印机 [ ^ ]



欲了解更多信息,请参阅此搜索结果: http://www.codeproject.com/search.aspx?q=Print+DataGridView&x=0&y=0&sbo=kw [ ^ ]


考虑更好的选择:不打印控件,从数据层打印用于填充/绑定控件的数据。它将使您的系统更加松散耦合。请参阅:

http://en.wikipedia.org/wiki/Loose_coupling [< a href =http://en.wikipedia.org/wiki/Loose_couplingtarget =_ blanktitle =New Window> ^ ]。



您应该拥有一个独特的数据层。数据层应该是UI控件的源和输出到打印机或报告。还有一个想法:如果你使用报告,打印只会抛出一个报告。



要打印,请使用类 System.Drawing.Printing.PrintDocument

http: //msdn.microsoft.com/en-us/library/system.drawing.printing.printdocument.aspx [ ^ ]。



-SA

In my windows application I want to print the data of a dataGridview control. I don't know what code I have to write please provide me some code.

解决方案

There are quite a few articles on CP; here are but a few:
Printing of DataGridView[^]
DataGridView Printing by Selecting Columns and Rows[^]
DataGridView Print/Print Preview Solution - Part I[^]
DataGridView Print/Print Preview Solution - Part II[^]
Another DataGridView Printer[^]

For more see this search result: http://www.codeproject.com/search.aspx?q=Print+DataGridView&x=0&y=0&sbo=kw[^]


Consider better alternative: don't print control, print data from your data layer which you use to populate/bind the control. It will make your system more loosely-coupled. Please see:
http://en.wikipedia.org/wiki/Loose_coupling[^].

You should have a distinct data layer. The data layer should be a source of UI control and the output to printer or reports. Yet another idea: if you use reports, print only throw a report.

For printing, use the class System.Drawing.Printing.PrintDocument:
http://msdn.microsoft.com/en-us/library/system.drawing.printing.printdocument.aspx[^].

—SA


这篇关于如何打印dataGridview控件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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