首页 > Windows开发 > 详细

C# DGVPrinter.cs 打印方法

时间:2016-09-01 12:41:13      阅读:1350      评论:0      收藏:0      [点我收藏+]

Code highlighting produced by Actipro CodeHighlighter (freeware)http://www.CodeHighlighter.com/--> 1 //
// 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);
}

 

////////////////////////////////////////

Code highlighting produced by Actipro CodeHighlighter (freeware)http://www.CodeHighlighter.com/--> 1 //
// 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);
}

C# DGVPrinter.cs 打印方法

原文:http://www.cnblogs.com/ilookbo/p/5829140.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!