本文档是参考网上的资料,稍加修改,经过实际编译,可实现
Winform
上
dataGridView
控
件的打印,
并实现分页,
下面为程序代码,仅供参考。本程序不需要在界面上添加任何打印
相关控件。
public
partial
class
Example
:
Form
{
//
打印文檔
PrintDocument
pdDocument =
new
PrintDocument
();
//
打印格式設置頁面
PageSetupDialog
dlgPageSetup =
new
PageSetupDialog
();
//
打印頁面
PrintDialog
dlgPrint =
new
PrintDialog
();
//
實例化打印預覽
PrintPreviewDialog
dlgPrintPreview =
new
PrintPreviewDialog
();
public
Example()
{
InitializeComponent();
pdDocument.PrintPage +&