Asp.Net教程,WinForm教程,Asp.Net MVC,vs2008教程,vs2010教程,Silverlight技术,源码下载,Asp.Net视频教程
全站热门标签
vs2010 Silverlight 存储过程 水晶报表 ADO.NET JavaScript LINQ AjaxPro DataGridView 面向对象 Extjs GridView XML DevExpress HTML教程 Oracle jQuery 分页 GDI+ Visual C++2010 MySQL Office2010 WPF MVC Dojo WCF4.0 VB.NET Sql2005 textbox cookie WCF WinForm Discuz!NT SQL经典语句 T-SQL checkbox ASPxGridView F# asp.net SQL VS2008新特性 DropDownList Access TreeView Ajax VS2008 页面执行时间 Flex 字符串 回调 VB2005 DataSet C#时间 ASP.NET性能优化 用户在线检测 动画
FrameworkC#技术 VB.NET VC.NET WCF WPF
当前位置: 主页 > WinForm教程 > C#技术 >

DataGridView打印类

时间:2010-08-15 20:50来源:未知 作者:admin 点击:

【简单用法】:


// Printing the DataGridView Control
// in response to a toolbar button press
  private void printToolStripButton_Click(object sender, EventArgs e)
 {
 DGVPrinter printer = new DGVPrinter();
 printer.Title = "DataGridView Report";
 printer.SubTitle = "An Easy to Use DataGridView Printing Object";
 printer.SubTitleFormatFlags = StringFormatFlags.LineLimit |
 StringFormatFlags.NoClip;
 printer.PageNumbers = true;
 printer.PageNumberInHeader = false;
 printer.PorportionalColumns = true;
 printer.HeaderCellAlignment = StringAlignment.Near;
 printer.Footer = "Your Company Name Here";
 printer.FooterSpacing = 15;
 printer.PrintDataGridView(datagridviewControl);
}

【复杂用法】:
  // Printing the DataGridView Control
 // in response to a toolbar button press – the myprintsettings and mypagesettings objects are objects used by the local
 // program to save printer and page settings
 private void printToolStripButton_Click(object sender, EventArgs e)
 {
 DGVPrinter printer = new DGVPrinter();
 printer.Title = "DataGridView Report";
printer.SubTitle = "An Easy to Use DataGridView Printing Object";
 printer.SubTitleFormatFlags = StringFormatFlags.LineLimit |
 StringFormatFlags.NoClip;
 printer.PageNumbers = true;
printer.PageNumberInHeader = false;
printer.PorportionalColumns = true;
printer.HeaderCellAlignment = StringAlignment.Near;
printer.Footer = "Your Company Name Here";
printer.FooterSpacing = 15;
// use saved settings

if (null != myprintsettings)
printer.PrintDocument.PrinterSettings = myprintsettings;
if (null != mypagesettings)
printer.PrintDocument.DefaultPageSettings = mypagesettings;
if (DialogResult.OK == printer.DisplayPrintDialog()) // replace DisplayPrintDialog() with your own print dialog
{
// save users' settings
 myprintsettings = printer.PrinterSettings;
 mypagesettings = printer.PageSettings;
// print without displaying the printdialog
 printer.PrintNoDisplay(datagridviewControl);
 }

DGVPrinter.zip

(责任编辑:admin)
Tags:DataGridView
责任编辑:admin
返回顶部
------分隔线----------------------------
推荐内容
骆驼户外男 真皮磨砂日常休闲鞋 低帮 2011秋冬新款 专柜正品特价 骆驼户外男 真皮磨砂日常休闲鞋 低帮 2011秋冬新款 专柜正品特价