• linkedu视频
  • 平面设计
  • 电脑入门
  • 操作系统
  • 办公应用
  • 电脑硬件
  • 动画设计
  • 3D设计
  • 网页设计
  • CAD设计
  • 影音处理
  • 数据库
  • 程序设计
  • 认证考试
  • 信息管理
  • 信息安全
菜单
linkedu.com
  • 网页制作
  • 数据库
  • 程序设计
  • 操作系统
  • CMS教程
  • 游戏攻略
  • 脚本语言
  • 平面设计
  • 软件教程
  • 网络安全
  • 电脑知识
  • 服务器
  • 视频教程
  • JavaScript
  • ASP.NET
  • PHP
  • 正则表达式
  • AJAX
  • JSP
  • ASP
  • Flex
  • XML
  • 编程技巧
  • Android
  • swift
  • C#教程
  • vb
  • vb.net
  • C语言
  • Java
  • Delphi
  • 易语言
  • vc/mfc
  • 嵌入式开发
  • 游戏开发
  • ios
  • 编程问答
  • 汇编语言
  • 微信小程序
  • 数据结构
  • OpenGL
  • 架构设计
  • qt
  • 微信公众号
您的位置:首页 > 程序设计 >C#教程 > C#打印绘图的实现方法

C#打印绘图的实现方法

作者: 字体:[增加 减小] 来源:互联网 时间:2017-05-28

通过本文主要向大家介绍了c#未实现该方法或操作,c#get set方法,c#invoke方法,c#方法,c#虚方法等相关知识,希望对您有所帮助,也希望大家支持linkedu.com www.linkedu.com

本文实例讲述了C#打印绘图的实现方法。分享给大家供大家参考。具体实现方法如下:

String drawString = "";
Font drawFont = null;
SolidBrush drawBrush = null;
float x = 0F;
float y = 0F;
StringFormat drawFormat = new StringFormat();

string test = "";

public string Test
{
    get { return test; }
    set { test = value; }
}
public Form1()
{
    InitializeComponent();
    //设置纸张大小
    PaperSize paperSize = new PaperSize("DataOrder", 1023, 614);
    printDocument1.DefaultPageSettings.PaperSize = paperSize;
}

//打印
private void button1_Click(object sender, EventArgs e)
{
    printDocument1.PrintPage += new PrintPageEventHandler(MyPrintDoc_PrintPage);
    try
    {
 printPreviewDialog1.Document = printDocument1;
 printPreviewDialog1.FormBorderStyle = FormBorderStyle.Fixed3D;
 printPreviewDialog1.ShowDialog();
 printDocument1.Print();
    }
    catch
    {

 MessageBox.Show("请安装打印机", "提示", MessageBoxButtons.OK, MessageBoxIcon.Error);
    }
}

protected void MyPrintDoc_PrintPage(object sender, PrintPageEventArgs e)
{
    //字体 颜色 格式 坐标
    drawFont = new Font("Arial", 8);
    drawBrush = new SolidBrush(Color.Black);
    x = 0F;
    y = 0F;
    drawFormat.FormatFlags = StringFormatFlags.NoWrap;

    //块数
    int num = 6;
    float weightAll = 12.600F;
    //标题
    //标题第一行
    string title = "钢板入库计量单";
    string BillCode = "吊号:" + "20080505170";
    string ClassType = "班别:" + "乙";
    string type1 = "类型:" + "定轧";
    string OrderNum = "记录单号:" + "QW-Y14-02-06";
    //标题第二行
    string ArriveStation = "到站:";
    string SpLine = "专用线:";
    string SaleNo = "销售订单号:";
    //标题第三行
    string AcceptName = "收货单位:" + "XXXX/12*2438*9144收二支";
    string time = DateTime.Now.Year.ToString() + "年" + DateTime.Now.Month.ToString().PadLeft(2,'0')+"月"+DateTime.Now.Day.ToString()+"日";
    //表格下数据
    string BoardNum = "合计:" + num.ToString() + "    块      " + weightAll.ToString()+"   吨   ";
    string CheckMan1 = "检查员:" + "";
    string MeName = "计量员:"+"XX";
    string CheckMan2 = "核对员:" + "";
    //线条长度
    Pen line = new Pen(drawBrush, 1);
    //绘图--字的位置
    //绘图--总标题
    e.Graphics.DrawString(title, drawFont, drawBrush, 400, 45, drawFormat);
    //绘图--标题--第一行
    //吊号
    e.Graphics.DrawString(BillCode, drawFont, drawBrush, 125,83, drawFormat);
    //班别
    e.Graphics.DrawString(ClassType, drawFont, drawBrush, 354, 83, drawFormat);
    //类型
    e.Graphics.DrawString(type1, drawFont, drawBrush, 500, 83, drawFormat);
    //记录单号
    e.Graphics.DrawString(OrderNum, drawFont, drawBrush, 685, 83, drawFormat);

    //绘图--标题--第二行
    //到站
    e.Graphics.DrawString(ArriveStation, drawFont, drawBrush, 125, 106, drawFormat);
    //专用线
    e.Graphics.DrawString(SpLine, drawFont, drawBrush, 354, 106, drawFormat);
    //销售订单号
    e.Graphics.DrawString(SaleNo, drawFont, drawBrush, 500, 106, drawFormat);

    //绘图--标题--第三行
    //收货单位
    e.Graphics.DrawString(AcceptName, drawFont, drawBrush, 125, 129, drawFormat);
    //时间
    e.Graphics.DrawString(time, drawFont, drawBrush, 685, 129, drawFormat);


    //绘图--表格下数据
    //合计
    e.Graphics.DrawString(BoardNum, drawFont, drawBrush, 125, 568, drawFormat);
    //检查员
    e.Graphics.DrawString(CheckMan1, drawFont, drawBrush, 400, 568, drawFormat);
    //计量员
    e.Graphics.DrawString(MeName, drawFont, drawBrush, 550, 568, drawFormat);
    //核对员
    e.Graphics.DrawString(CheckMan2, drawFont, drawBrush, 700, 568, drawFormat);

    //绘图 表格
    float leftbianJu = 120;
    float topbianJu = 152;
    float tableWidth = 770;
    float tableHeight = 393;

    float cellwidth = 55;
    float cellwidth1 = 110;
    float cellheigh = 0F;

    //绘图--线的位置 外边矩形
    //横
    e.Graphics.DrawLine(line, leftbianJu, topbianJu,leftbianJu+tableWidth,topbianJu);
    e.Graphics.DrawLine(line, leftbianJu, topbianJu + tableHeight, leftbianJu + tableWidth, topbianJu + tableHeight);
    //竖
    e.Graphics.DrawLine(line, leftbianJu, topbianJu, leftbianJu, topbianJu+tableHeight);
    e.Graphics.DrawLine(line, leftbianJu + tableWidth, topbianJu, leftbianJu + tableWidth, topbianJu + tableHeight);
    //e.Graphics.DrawLine(line, 15, 0, 15, 614);

    //绘图--内部竖线的位置
    y = topbianJu+tableHeight;
    x = leftbianJu + cellwidth;
    e.Graphics.DrawLine(line, x, topbianJu, x,y );
    x= leftbianJu + cellwidth + cellwidth1;
    e.Graphics.DrawLine(line,x , topbianJu, x, y);
    x = leftbianJu + cellwidth + cellwidth1 * 2;
    e.Graphics.DrawLine(line, x, topbianJu, x, y);
    x = leftbianJu + cellwidth + cellwidth1 * 3;
    e.Graphics.DrawLine(line, x, topbianJu, x, y);
    x = leftbianJu + cellwidth * 2 + cellwidth1 * 3;
    e.Graphics.DrawLine(line, x, topbianJu, x, y);
    x = leftbianJu + cellwidth * 3 + cellwidth1 * 3;
    e.Graphics.DrawLine(line, x, topbianJu, x, y);
    x = leftbianJu + cellwidth * 4 + cellwidth1 * 3;
    e.Graphics.DrawLine(line, x, topbianJu, x, y);
    x = leftbianJu + cellwidth * 5 + cellwidth1 * 3;
 &nbs

分享到:QQ空间新浪微博腾讯微博微信百度贴吧QQ好友复制网址打印

您可能想查找下面的文章:

  • C#实现组合排列的方法
  • c#图片上传和显示的实现方法
  • C#实现简单播放mp3的方法
  • C#实现随机洗牌的方法
  • C#打印绘图的实现方法
  • C#播放铃声最简单实现方法
  • C#中实现多继承的方法
  • C#中实现屏蔽Ctrl+C的方法
  • C#实现图片上传与浏览切换的方法
  • C# TrieTree介绍及实现方法

相关文章

  • 2017-05-28C#中is与As运算符号的使用详解
  • 2017-05-28C#使用NPOI上传excel
  • 2017-05-28C#读取配置文件的方法汇总
  • 2017-05-28richtextbox控件插入链接代码分享
  • 2017-05-28C#的四个基本技巧
  • 2017-05-28C#查询SqlServer数据库并返回单个值的方法
  • 2017-05-28浅析C#静态类,静态构造函数,静态变量
  • 2017-05-28那些年,我还在学习C# 学习笔记
  • 2017-05-28C#中实现查找mysql的安装路径
  • 2017-05-28为什么哈希存取比较快?使用它需要付出什么代价

文章分类

  • JavaScript
  • ASP.NET
  • PHP
  • 正则表达式
  • AJAX
  • JSP
  • ASP
  • Flex
  • XML
  • 编程技巧
  • Android
  • swift
  • C#教程
  • vb
  • vb.net
  • C语言
  • Java
  • Delphi
  • 易语言
  • vc/mfc
  • 嵌入式开发
  • 游戏开发
  • ios
  • 编程问答
  • 汇编语言
  • 微信小程序
  • 数据结构
  • OpenGL
  • 架构设计
  • qt
  • 微信公众号

最近更新的内容

    • C#的正则表达式Regex类使用简明教程
    • C#实现Stream与byte[]之间的转换实例教程
    • C#使用Object类实现栈的方法详解
    • C#实现Menu和ContextMenu自定义风格及contextMenu自定义
    • C#关闭指定名字进程的方法
    • C#获取CPU处理器核心数量的方法
    • C# WinForm控件对透明图片重叠时出现图片不透明的简单解决方法
    • DirectInfo.GetFiles返回数组的默认排序示例
    • C#利用性能计数器监控网络状态
    • C#打开php链接传参然后接收返回值的关键代码

关于我们 - 联系我们 - 免责声明 - 网站地图

©2020-2025 All Rights Reserved. linkedu.com 版权所有