1.窗体添加一个button
2.代码如下:
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Drawing.Printing;
using System.Diagnostics;
using System.IO;
namespace printForm
{
public partial class Form1 : Form
{
private string stringToPrint;
public Form1()
{
InitializeComponent();
this.printDocument1.PrintPage += new PrintPageEventHandler(this.myPrinter_PrintPage);
}
private void myPrinter_PrintPage(object sender, PrintPageEventArgs e)
{

本文档通过C#展示了如何实现打印功能,利用printDocument组件和PrintPage事件处理程序来绘制要打印的内容。在button点击事件中,读取指定路径的txt文件,并设置打印控制器以消除"正在打印"的提示窗体。
最低0.47元/天 解锁文章
3611

被折叠的 条评论
为什么被折叠?



