基本信息
源码名称:C# 套打Demo
源码大小:0.03M
文件格式:.rar
开发语言:C#
更新时间:2020-11-13
友情提示:(无需注册或充值,赞助后即可获取资源下载链接)
嘿,亲!知识可是无价之宝呢,但咱这精心整理的资料也耗费了不少心血呀。小小地破费一下,绝对物超所值哦!如有下载和支付问题,请联系我们QQ(微信同号):78630559
本次赞助数额为: 2 元×
微信扫码支付:2 元
×
请留下您的邮箱,我们将在2小时内将文件发到您的邮箱
源码介绍
套打Demo
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 Print_Demo
{
public partial class Form1 : Form
{
public PrintDocument printDt = new PrintDocument(); //打印文档对象
Font printFont; //打印使用的字体
public Form1()
{
InitializeComponent();
}
void printDt_PrintPage(object sender, PrintPageEventArgs e)
{
float pointX = 10;
float pointY = 10;
e.Graphics.DrawString("打印内容", new Font("宋体", 16F), Brushes.Black, pointX 60, pointY);
e.Graphics.DrawLine(new Pen(Color.Black), pointX, pointY 26,pointX 300,pointY 26);
e.Graphics.DrawString("打印内容", printFont, Brushes.Black, pointX, pointY 35);
e.Graphics.DrawLine(new Pen(Color.Black), pointX, pointY 56, pointX 300, pointY 56);
e.Graphics.DrawString("打印内容", printFont, Brushes.Black, pointX, pointY 65);
e.Graphics.DrawLine(new Pen(Color.Black), pointX, pointY 86, pointX 300, pointY 86);
e.Graphics.DrawString("打印内容", printFont, Brushes.Black, pointX, pointY 95);
e.Graphics.DrawLine(new Pen(Color.Black), pointX, pointY 116, pointX 300, pointY 116);
e.Graphics.DrawString("打印内容", printFont, Brushes.Black, pointX, pointY 125);
e.Graphics.DrawLine(new Pen(Color.Black), pointX, pointY 146, pointX 300, pointY 146);
e.Graphics.DrawString("打印内容", printFont, Brushes.Black, pointX, pointY 155);
e.Graphics.DrawLine(new Pen(Color.Black), pointX, pointY 176, pointX 300, pointY 176);
e.Graphics.DrawString("打印内容", printFont, Brushes.Black, pointX, pointY 185);
e.Graphics.DrawLine(new Pen(Color.Black), pointX, pointY 206, pointX 300, pointY 206);
e.Graphics.DrawString("检测结果", printFont, Brushes.Black, pointX, pointY 233);
e.Graphics.DrawString("通过", new Font("宋体",22F,FontStyle.Bold), Brushes.Black, pointX 90, pointY 225);
e.Graphics.DrawLine(new Pen(Color.Black), pointX, pointY 265, pointX 300, pointY 265);
e.Graphics.DrawString("单位名称", printFont, Brushes.Black, pointX, pointY 275);
}
private void Form1_Load(object sender, EventArgs e)
{
printDt.PrintPage = new PrintPageEventHandler(printDt_PrintPage);
printFont = new Font("宋体", 12F);
}
private void btnPrint_Click(object sender, EventArgs e)
{
//PrintDialog printDlg = new PrintDialog();
//printDlg.Document = printDt;
//printDlg.AllowPrintToFile = true;
//printDlg.AllowCurrentPage = true;
//printDlg.AllowSelection = true;
//printDlg.ShowDialog();
//printDlg.ShowDialog();
printDt.Print();
}
private void btnLook_Click(object sender, EventArgs e)
{
PrintPreviewDialog printPreview = new PrintPreviewDialog();
printPreview.PrintPreviewControl.Document = printDt;
printPreview.ShowDialog(this);
}
}
}