using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using System.Drawing.Printing; namespace Zsh.print
{
public partial class frmBadHzd : Form
{
public frmBadHzd()
{
InitializeComponent();
} private void frmBadHzd_Paint(object sender, PaintEventArgs e)
{
Font font;
string str;
float xPos; //x点坐标
 float yPos; //y点的坐标
  float topMargin = ;
float leftMargin = ; font = new Font("宋体", );
str = "欢迎光临";
xPos = leftMargin + ;
yPos = topMargin;
e.Graphics.DrawString(str, font, Brushes.Black, xPos, yPos, new StringFormat()); xPos = leftMargin;
yPos = yPos + font.GetHeight(e.Graphics) + ;
font = new Font("黑体", );
str = "---------------------------------";
e.Graphics.DrawString(str, font, Brushes.Black, xPos, yPos, new StringFormat()); xPos = leftMargin + ;
yPos = yPos + font.GetHeight(e.Graphics) + ;
font = new Font("黑体", );
str = "客 户 回 执 单";
e.Graphics.DrawString(str, font, Brushes.Black, xPos, yPos, new StringFormat()); xPos = leftMargin;
yPos = yPos + font.GetHeight(e.Graphics) + ;
font = new Font("黑体", );
str = "---------------------------------";
e.Graphics.DrawString(str, font, Brushes.Black, xPos, yPos, new StringFormat()); xPos = leftMargin;
yPos = yPos + font.GetHeight(e.Graphics) + ;
font = new Font("宋体", );
str = " 凭单号";
e.Graphics.DrawString(str, font, Brushes.Black, xPos, yPos, new StringFormat()); xPos = leftMargin;
yPos = yPos + font.GetHeight(e.Graphics) + ;
font = new Font("宋体", );
str = "业务类型";
e.Graphics.DrawString(str, font, Brushes.Black, xPos, yPos, new StringFormat()); xPos = leftMargin;
yPos = yPos + font.GetHeight(e.Graphics) + ;
font = new Font("宋体", );
str = " 卡号";
e.Graphics.DrawString(str, font, Brushes.Black, xPos, yPos, new StringFormat()); xPos = leftMargin;
yPos = yPos + font.GetHeight(e.Graphics) + ;
font = new Font("宋体", );
str = " 原余额";
e.Graphics.DrawString(str, font, Brushes.Black, xPos, yPos, new StringFormat()); xPos = leftMargin;
yPos = yPos + font.GetHeight(e.Graphics) + ;
font = new Font("宋体", );
str = " 现余额";
e.Graphics.DrawString(str, font, Brushes.Black, xPos, yPos, new StringFormat()); xPos = leftMargin;
yPos = yPos + font.GetHeight(e.Graphics) + ;
font = new Font("黑体", );
str = "---------------------------------";
e.Graphics.DrawString(str, font, Brushes.Black, xPos, yPos, new StringFormat()); xPos = leftMargin + ;
yPos = yPos + font.GetHeight(e.Graphics) + ;
font = new Font("宋体", );
str = "客户签名";
e.Graphics.DrawString(str, font, Brushes.Black, xPos, yPos, new StringFormat()); xPos = leftMargin + ;
yPos = yPos + font.GetHeight(e.Graphics) - ;
font = new Font("宋体", );
str = "-----------";
e.Graphics.DrawString(str, font, Brushes.Black, xPos, yPos, new StringFormat()); xPos = leftMargin;
yPos = yPos + font.GetHeight(e.Graphics);
font = new Font("宋体", );
str = "受理单位名称";
e.Graphics.DrawString(str, font, Brushes.Black, xPos, yPos, new StringFormat()); xPos = leftMargin;
yPos = yPos + font.GetHeight(e.Graphics) + ;
font = new Font("宋体", );
str = " 操作员名称";
e.Graphics.DrawString(str, font, Brushes.Black, xPos, yPos, new StringFormat()); xPos = leftMargin + ;
yPos = yPos + font.GetHeight(e.Graphics) + ;
font = new Font("宋体", );
str = "   日期";
e.Graphics.DrawString(str, font, Brushes.Black, xPos, yPos, new StringFormat()); xPos = leftMargin;
yPos = yPos + font.GetHeight(e.Graphics) + ;
font = new Font("黑体", );
str = "---------------------------------";
e.Graphics.DrawString(str, font, Brushes.Black, xPos, yPos, new StringFormat()); xPos = leftMargin;
yPos = yPos + font.GetHeight(e.Graphics) + ;
font = new Font("华文行楷", );
str = "此凭单为购物凭证,请妥善保管!";
e.Graphics.DrawString(str, font, Brushes.Black, xPos, yPos, new StringFormat());
} private void printDocument1_PrintPage(object sender, PrintPageEventArgs e)
{
Font font;
string str;
float xPos; //x点坐标
 float yPos; //y点的坐标
 float topMargin = ;
float leftMargin = ; font = new Font("宋体", );
str = "欢迎光临";
xPos = leftMargin + ;
yPos = topMargin;
e.Graphics.DrawString(str, font, Brushes.Black, xPos, yPos, new StringFormat()); xPos = leftMargin;
yPos = yPos + font.GetHeight(e.Graphics) + ;
font = new Font("黑体", );
str = "---------------------------------";
e.Graphics.DrawString(str, font, Brushes.Black, xPos, yPos, new StringFormat()); xPos = leftMargin + ;
yPos = yPos + font.GetHeight(e.Graphics) + ;
font = new Font("黑体", );
str = "客 户 回 执 单";
e.Graphics.DrawString(str, font, Brushes.Black, xPos, yPos, new StringFormat()); xPos = leftMargin;
yPos = yPos + font.GetHeight(e.Graphics) + ;
font = new Font("黑体", );
str = "---------------------------------";
e.Graphics.DrawString(str, font, Brushes.Black, xPos, yPos, new StringFormat()); xPos = leftMargin;
yPos = yPos + font.GetHeight(e.Graphics) + ;
font = new Font("宋体", );
str = " 凭单号";
e.Graphics.DrawString(str, font, Brushes.Black, xPos, yPos, new StringFormat()); xPos = leftMargin;
yPos = yPos + font.GetHeight(e.Graphics) + ;
font = new Font("宋体", );
str = "业务类型";
e.Graphics.DrawString(str, font, Brushes.Black, xPos, yPos, new StringFormat()); xPos = leftMargin;
yPos = yPos + font.GetHeight(e.Graphics) + ;
font = new Font("宋体", );
str = " 卡号";
e.Graphics.DrawString(str, font, Brushes.Black, xPos, yPos, new StringFormat()); xPos = leftMargin;
yPos = yPos + font.GetHeight(e.Graphics) + ;
font = new Font("宋体", );
str = " 原余额";
e.Graphics.DrawString(str, font, Brushes.Black, xPos, yPos, new StringFormat()); xPos = leftMargin;
yPos = yPos + font.GetHeight(e.Graphics) + ;
font = new Font("宋体", );
str = " 现余额";
e.Graphics.DrawString(str, font, Brushes.Black, xPos, yPos, new StringFormat()); xPos = leftMargin;
yPos = yPos + font.GetHeight(e.Graphics) + ;
font = new Font("黑体", );
str = "---------------------------------";
e.Graphics.DrawString(str, font, Brushes.Black, xPos, yPos, new StringFormat()); xPos = leftMargin + ;
yPos = yPos + font.GetHeight(e.Graphics) + ;
font = new Font("宋体", );
str = "客户签名";
e.Graphics.DrawString(str, font, Brushes.Black, xPos, yPos, new StringFormat()); xPos = leftMargin + ;
yPos = yPos + font.GetHeight(e.Graphics) - ;
font = new Font("宋体", );
str = "-----------";
e.Graphics.DrawString(str, font, Brushes.Black, xPos, yPos, new StringFormat()); xPos = leftMargin;
yPos = yPos + font.GetHeight(e.Graphics);
font = new Font("宋体", );
str = "受理单位名称";
e.Graphics.DrawString(str, font, Brushes.Black, xPos, yPos, new StringFormat()); xPos = leftMargin;
yPos = yPos + font.GetHeight(e.Graphics) + ;
font = new Font("宋体", );
str = " 操作员名称";
e.Graphics.DrawString(str, font, Brushes.Black, xPos, yPos, new StringFormat()); xPos = leftMargin + ;
yPos = yPos + font.GetHeight(e.Graphics) + ;
font = new Font("宋体", );
str = "   日期";
e.Graphics.DrawString(str, font, Brushes.Black, xPos, yPos, new StringFormat()); xPos = leftMargin;
yPos = yPos + font.GetHeight(e.Graphics) + ;
font = new Font("黑体", );
str = "---------------------------------";
e.Graphics.DrawString(str, font, Brushes.Black, xPos, yPos, new StringFormat()); xPos = leftMargin;
yPos = yPos + font.GetHeight(e.Graphics) + ;
font = new Font("华文行楷", );
str = "此凭单为购物凭证,请妥善保管!";
e.Graphics.DrawString(str, font, Brushes.Black, xPos, yPos, new StringFormat());
} /// <summary>
/// 打印票据信息
/// </summary>
/// <param name="?">打印机名称</param>
/// <param name="sho_printNum">打印数量</param>
public void print(string str_Printer, short sho_printNum)
{
try
{
PrintDocument pd = new PrintDocument();
pd.PrinterSettings.PrinterName = str_Printer;
pd.PrinterSettings.Copies = sho_printNum;
pd.PrintController = new StandardPrintController();
pd.PrintPage += new PrintPageEventHandler(printDocument1_PrintPage);
if (pd.PrinterSettings.IsValid)
{
pd.Print();
}
else
{
MessageBox.Show("打印机连接错误", "错误", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
catch (Exception e)
{
MessageBox.Show(e.Message);
}
}
}
}

源码源于 ==》 http://bbs.csdn.net/topics/310215237

C# winform 打印事例的更多相关文章

  1. WinForm打印

    WinForm打印要用打印控件: PageSetupDialog:打印设置对话框 PrintDialog:打印对话框 PrintDocument:要打印的对象,非常重要 PrintPreviewCon ...

  2. c# winform打印excel(使用NPOI+Spire.xls+PrintDocument直接打印excel)

    前言 c#做winform程序要求生成并打印Excel报告,为了不安装Office相应组件,我选择了NPOI来生成Excel报告,用winform的PrintDocument控件来触发打印操作,而难点 ...

  3. winForm 打印预览

    自己很少写技术博客,虽然已经干程序员两年多了,winform开发,web开发都干过,不论项目大小对于.net的相关技术也是了解的,如mvc,wcf,wpf,silverlight,socekt通讯,n ...

  4. [asp.net]c# winform打印类

    using System; using System.Collections.Generic; using System.Text; using System.Windows.Forms; using ...

  5. winform 打印控件

    (1)PageSetupDialog1    打印设置窗口  (2)PrintDocument     向打印机输送的对象 事件:PrintPage   对于打印的每一页都执行一次 (3)PrintP ...

  6. Winform 打印PDF顺序混乱,获取打印队列

    工作中PDF打印顺序混乱着实让我疼痛了好久,其实决绝方法非常简单,但没有想到这个点子的时候确实让我走了很多弯路 这里文章写出来并不是为了炫耀什么,只是觉得发现些好东西就分享出来而已,同时也做个记录,方 ...

  7. C# winform打印总结 z

    http://blog.csdn.net/jing_xin/article/details/41444063 针对BEIYANG收据打印机 BTP-R580测试通过. 操作说明:http://www. ...

  8. WinForm打印之页边距

    1.启用页边距: 默认情况下PrintDocument是不理会页边距的(MS再次让人无语...),这也是为什么有人说明明设了页边距在打印预览里却没有效果的原因. 解决办法是设置PrintDocumen ...

  9. 【2017-05-03】winform打印控件、事件对象和事件数据、MDI窗体容器

    一.打印控件 第一步先把打印对象搞出来. - printDocument    打印对象(将要打印的内容放到该对象里,从该对象里取内容打印) 设置他的PrintPage事件(对于要打印的每一页触发一次 ...

随机推荐

  1. 开源.net 混淆器ConfuserEx介绍 [转]

    今天给大家介绍一个开源.net混淆器——ConfuserEx http://yck1509.github.io/ConfuserEx/ 由于项目中要用到.net 混淆器,网上搜寻了很多款,比如Dotf ...

  2. ToolkitScriptManager vs. ScriptManager 关于“只能向页面中添加 ScriptManager 的一个实例”讨论

    在使用ASP.NET设计AJAX功能网页时,需要首先声明ToolkitScriptManager或者ScriptManager控件,这些全局的脚本核心控制,然后才能使用众多的AJAX控件.如果没有创建 ...

  3. Node.js环境搭建&&npm安装

    Node.js环境搭建 什么使Node.js呢?我们知道JavaScript开始作为客户端语言,但早已在浏览器端一统江湖,这时,野心越来越大,它就想向服务器端拓展了,于是Node.js就是这样的,我们 ...

  4. Webapps初步_认识HTTP例子程序读取

    package servlet_01; import java.io.BufferedReader; import java.io.InputStreamReader; import java.io. ...

  5. 运行零币Zcash(ZEC)

    1.在基于 Ubuntu 或者 Debian 的系统中: $ sudo apt-get install \build-essential pkg-config libc6-dev m4 g++-mul ...

  6. struts2 ognl存放数据

    ongl存放数据可以存放在对象栈(root),也可以存放在map中 一.存放在map中 1.存放在map中可以分为存放在request.session.application public Strin ...

  7. PHP代码实现强制换行

    1. 简单的,只能分2行: //$str:输入字符串: //$num:超过多少个字符后进行换行(换行后每行的最大字符数) function forceBlackString($str, $num){ ...

  8. 查找checked的checkbox和raido

    <fieldset id="checkArray"> <input type="checkbox" name="chk[]" ...

  9. 【angular5项目积累总结】panel组件

    view code panel.component.css :host { display:flex; min-width:300px } panel.component.html <heade ...

  10. JavaScript es6 class类的理解。

    本着互联网的分享精神,在本篇文章我将会把我对JavaScript  es6 class类的理解分享给大家. JavaScript 类主要是 JavaScript 现有的基于原型的继承的语法糖. 类语法 ...