DataGridView打印类

DataGridView打印类

/Files/zhuqil/DGVPrinter.zip

 作者: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  }
复制代码

【复杂用法】:

复制代码
 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  }
复制代码
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值