C# DGVPrinter.cs 打印方法
2016-09-01 11:29
435 查看
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);
}
// 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#方法【Format.CS】
- 在VS2008中使用C#代码打印 RichTextBox 控件的内容[方法采自微软支持][Part 1]
- C#操作word的一些基本方法(word打印,插入文件,插入图片,定位页眉页脚,去掉横线)
- 黑马程序员-c#基础加强版之方法控制流复习-3控制台打印密码
- C#中很模糊查询DGV中数据的两种方法
- C#使用异步Socket实现TCP网络服务的CS的通讯构架(二)使用方法
- C# 打印出发生错误的文件,方法,代码所在行和列
- C# 打印 word pdf PrintOut方法
- 分享 tsc 条码打印机 打印控件 调用方法 , c# silverlight
- C#双面打印解决方法(打印word\excel\图片)
- 在VS2008中使用C#代码打印 RichTextBox 控件的内容[方法采自微软支持][Part 2]
- C#.net 后台cs 调用前台javascript 的方法
- 关于DGVPrinter.cs中的PrintRange
- C#后台调用LPT1端口实现小票机打印方法。
- C#操作word的一些基本方法(word打印,插入文件,插入图片,定位页眉页脚,去掉横线)
- .Net中的打印A4纸如何实现(以C#为例)——VB中的Printer.Print在.Net中如何实现
- C#与ASP.NET(CS与BS)结合开发应用传递参数的方法
- C# 中打印、预览、打印机设置和打印属性的方法
- C#程序动态设定打印选项 [Programmatically selecting complex printer options in C#]
- C#.Net集成Bartender条码打印的方法(泪流满面终于解决!)