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
本文版权归作者和博客园共有,欢迎转载,但未经作者同意必须保留此段声明,且在文章页面明显位置给出原文连接,否则保留追究法律责任的权利。
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】凌霞软件回馈社区,博客园 & 1Panel & Halo 联合会员上线
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· 智能桌面机器人:用.NET IoT库控制舵机并多方法播放表情
· Linux glibc自带哈希表的用例及性能测试
· 深入理解 Mybatis 分库分表执行原理
· 如何打造一个高并发系统?
· .NET Core GC压缩(compact_phase)底层原理浅谈
· 手把手教你在本地部署DeepSeek R1,搭建web-ui ,建议收藏!
· 新年开篇:在本地部署DeepSeek大模型实现联网增强的AI应用
· Janus Pro:DeepSeek 开源革新,多模态 AI 的未来
· 互联网不景气了那就玩玩嵌入式吧,用纯.NET开发并制作一个智能桌面机器人(三):用.NET IoT库
· 【非技术】说说2024年我都干了些啥