DataGridView打印类
作者:http://www.codeproject.com/KB/printing/DGVPrinter.aspx
【简单用法】:
1 //
2 // Printing the DataGridView Control
3 // in response to a toolbar button press
4 //
5 private void printToolStripButton_Click(object sender, EventArgs e)
6 {
7 DGVPrinter printer = new DGVPrinter();
8 printer.Title = "DataGridView Report";
9 printer.SubTitle = "An Easy to Use DataGridView Printing Object";
10 printer.SubTitleFormatFlags = StringFormatFlags.LineLimit |
11 StringFormatFlags.NoClip;
12 printer.PageNumbers = true;
13 printer.PageNumberInHeader = false;
14 printer.PorportionalColumns = true;
15 printer.HeaderCellAlignment = StringAlignment.Near;
16 printer.Footer = "Your Company Name Here";
17 printer.FooterSpacing = 15;
18 printer.PrintDataGridView(datagridviewControl);
19 }
2 // Printing the DataGridView Control
3 // in response to a toolbar button press
4 //
5 private void printToolStripButton_Click(object sender, EventArgs e)
6 {
7 DGVPrinter printer = new DGVPrinter();
8 printer.Title = "DataGridView Report";
9 printer.SubTitle = "An Easy to Use DataGridView Printing Object";
10 printer.SubTitleFormatFlags = StringFormatFlags.LineLimit |
11 StringFormatFlags.NoClip;
12 printer.PageNumbers = true;
13 printer.PageNumberInHeader = false;
14 printer.PorportionalColumns = true;
15 printer.HeaderCellAlignment = StringAlignment.Near;
16 printer.Footer = "Your Company Name Here";
17 printer.FooterSpacing = 15;
18 printer.PrintDataGridView(datagridviewControl);
19 }
【复杂用法】:
1 //
2 // Printing the DataGridView Control
3 // in response to a toolbar button press – the myprintsettings and mypagesettings objects are objects used by the local
4 // program to save printer and page settings
5 //
6 private void printToolStripButton_Click(object sender, EventArgs e)
7 {
8 DGVPrinter printer = new DGVPrinter();
9 printer.Title = "DataGridView Report";
10 printer.SubTitle = "An Easy to Use DataGridView Printing Object";
11 printer.SubTitleFormatFlags = StringFormatFlags.LineLimit |
12 StringFormatFlags.NoClip;
13 printer.PageNumbers = true;
14 printer.PageNumberInHeader = false;
15 printer.PorportionalColumns = true;
16 printer.HeaderCellAlignment = StringAlignment.Near;
17 printer.Footer = "Your Company Name Here";
18 printer.FooterSpacing = 15;
19 // use saved settings
20 if (null != myprintsettings)
21 printer.PrintDocument.PrinterSettings = myprintsettings;
22 if (null != mypagesettings)
23 printer.PrintDocument.DefaultPageSettings = mypagesettings;
24 if (DialogResult.OK == printer.DisplayPrintDialog()) // replace DisplayPrintDialog() with your own print dialog
25 {
26 // save users' settings
27 myprintsettings = printer.PrinterSettings;
28 mypagesettings = printer.PageSettings;
29 // print without displaying the printdialog
30 printer.PrintNoDisplay(datagridviewControl);
31 }
2 // Printing the DataGridView Control
3 // in response to a toolbar button press – the myprintsettings and mypagesettings objects are objects used by the local
4 // program to save printer and page settings
5 //
6 private void printToolStripButton_Click(object sender, EventArgs e)
7 {
8 DGVPrinter printer = new DGVPrinter();
9 printer.Title = "DataGridView Report";
10 printer.SubTitle = "An Easy to Use DataGridView Printing Object";
11 printer.SubTitleFormatFlags = StringFormatFlags.LineLimit |
12 StringFormatFlags.NoClip;
13 printer.PageNumbers = true;
14 printer.PageNumberInHeader = false;
15 printer.PorportionalColumns = true;
16 printer.HeaderCellAlignment = StringAlignment.Near;
17 printer.Footer = "Your Company Name Here";
18 printer.FooterSpacing = 15;
19 // use saved settings
20 if (null != myprintsettings)
21 printer.PrintDocument.PrinterSettings = myprintsettings;
22 if (null != mypagesettings)
23 printer.PrintDocument.DefaultPageSettings = mypagesettings;
24 if (DialogResult.OK == printer.DisplayPrintDialog()) // replace DisplayPrintDialog() with your own print dialog
25 {
26 // save users' settings
27 myprintsettings = printer.PrinterSettings;
28 mypagesettings = printer.PageSettings;
29 // print without displaying the printdialog
30 printer.PrintNoDisplay(datagridviewControl);
31 }
(全文完)
以下为广告部分
您部署的HTTPS网站安全吗?
如果您想看下您的网站HTTPS部署的是否安全,花1分钟时间来 myssl.com 检测以下吧。让您的HTTPS网站变得更安全!
快速了解HTTPS网站安全情况。
安全评级(A+、A、A-...)、行业合规检测、证书信息查看、证书链信息以及补完、服务器套件信息、证书兼容性检测等。
安装部署SSL证书变得更方便。
SSL证书内容查看、SSL证书格式转换、CSR在线生成、SSL私钥加解密、CAA检测等。
让服务器远离SSL证书漏洞侵扰
TLS ROBOT漏洞检测、心血漏洞检测、FREAK Attack漏洞检测、SSL Poodle漏洞检测、CCS注入漏洞检测。
作者:朱祁林
出处:http://zhuqil.cnblogs.com
本文版权归作者和博客园共有,欢迎转载,但未经作者同意必须保留此段声明,且在文章页面明显位置给出原文连接,否则保留追究法律责任的权利。