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 打印方法的更多相关文章

  1. DebugLog 打印方法执行时间

    DebugLog 打印方法执行时间 用于方便调试性能问题的打印插件.给访法加上@DebugLog,就能输出该方法的调用参数,以及执行时间. Project gradle配置 // Top-level ...

  2. 转网页WB.ExecWB控件打印方法

    网页WB.ExecWB控件打印方法 2010-02-01 12:48 代码: <table width="100%" cellpadding="1" on ...

  3. atitit. js 跨界面 页面 web cs 传值方法总结

    atitit. js 跨界面 页面 web cs 传值方法总结 #--需求 js #---两个方法:   直接传跟跟间接传递... 1.直接传跟new form(param)    web使用url方 ...

  4. js打印方法总结

    前段时间做web项目用到了页面打印,在网上找了些资料,自己也试了很多方法,将这些方案列出下: 1.window.print()方法打印,所有主要浏览器都支持 print() 方法 这个方法很实用,只需 ...

  5. 实现Square类,让其继承自Rectangle类,并在Square类增添新属性和方法,在2的基础上,在Square类中重写Rectangle类中的初始化和打印方法

    实现Square类,让其继承自Rectangle类,并在Square类增添新属性和方法,在2的基础上,在Square类中重写Rectangle类中的初始化和打印方法 #import <Found ...

  6. Swift中自定义Log打印方法

    系统如何调用super方法 系统默认只会在构造函数中,自动调用super.init()方法,而且是在所写方法的尾部进行调用. 在其他函数中,如何需要调用父类的默认实现,都需要手动去实现. 如果在构造函 ...

  7. ASHX呼叫ASPX.cs的方法

    ASHX呼叫ASPX.cs的方法 问题来自论坛,有网友这样的要求,在ASHX内呼叫ASPX.cs的一个方法或函数. 在一个网站中,也许不止只有一个aspx网页.把aspx.cs内的方法宣告为publi ...

  8. Swift中自定义打印方法

    // 1.获取打印所在的文件 let file = ( #file as NSString).lastPathComponent // 2.获取打印所在的方法 let funcName = #func ...

  9. ASCX呼叫ASPX.CS的方法

    为了安全设计,一般情况之下,改用为接口(interface). 在网页中实现这个接口: 用户控件: 当然,把用户控件ascx拉至网页之后,在用户控件的linkbutton的click事件,就可以呼叫至 ...

随机推荐

  1. python并发编程之多进程1-----------互斥锁与进程间的通信

    一.互斥锁 进程之间数据隔离,但是共享一套文件系统,因而可以通过文件来实现进程直接的通信,但问题是必须自己加锁处理. 注意:加锁的目的是为了保证多个进程修改同一块数据时,同一时间只能有一个修改,即串行 ...

  2. 自己没有记住的一点小知识(ORM查询相关)

    一.多对多的正反向查询 class Class(models.Model): name = models.CharField(max_length=32,verbose_name="班级名& ...

  3. dubbo源码之服务消费

    消费端启动初始化过程: 消费端的代码解析也是从配置文件解析开始的,服务发布对应的<dubbo:service,解析xml的时候解析了一个ServiceBean,并且调用ServiceConfig ...

  4. 将本地代码通过git命令上传到github的流程

    首先在项目根目录打开命令行或者直接打开git-bash转到项目根目录下 1.创建本地仓库 $ git init 初始化本地仓库 $ git add --all 将项目文件添加到跟踪列表 $ git c ...

  5. hdu4612 卡cin e-DCC缩点

    /* 给定无向图,求加入一条边后最少剩下多少桥 */ #include<bits/stdc++.h> using namespace std; #define maxn 200005 #d ...

  6. hdu2460 e-DCC染色缩点+暴力LCA

    /* 给定一个无向图,往里面加边,问加第i条边时图中的桥数 首先肯定要求初始状态下的桥,染色缩点 每次给定的边为(u,v), 那么u->lca(u,v)->v路上的所有边都不再是桥 求LC ...

  7. RFC2119:RFC协议动词含义

    协议地址:http://www.ietf.org/rfc/rfc2119.txt MUST 必须的.通过它描述的对象,是强制要求的.它与REQUIRED和SHALL含义相同. MUST NOT 不允许 ...

  8. Django系列(一)

    项目引入静态文件 更改settings.py,为项目下面的每个APP应用,建立静态文件,这里如blog,首先在blog下面建立一个静态文件夹名为statics,注意这里为别名 STATICFILES_ ...

  9. photoshop CC智能切图

    网页设计在技术层面上,第一步是美工做出网页效果图,第二步就是网页前端进行网页切图.网页切图工具常用的有fireworks.PS,这里使用PS进行网页切图. 我们通过设计稿,得到我们想要的产出物(如.p ...

  10. 浅析H5图片上传

    概述 最近需求上需要实现图片上传的功能,简单记录下实现过程.目前实现的功能比较简单,主要有以下几点: 图片预览 图片删除 拖拽上传 压缩上传 移动端实现方案:使用File API 主要使用到 File ...