C#根本打印事宜用法實例。本站提示廣大學習愛好者:(C#根本打印事宜用法實例)文章只能為提供參考,不一定能成為您想要的結果。以下是C#根本打印事宜用法實例正文
本文實例講述了C#根本打印事宜用法。分享給年夜家供年夜家參考。詳細以下:
using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Text; using System.Windows.Forms; namespace WindowsApplication3 { public partial class Form5 : Form { string filename = "myfile.txt"; Font printerfont = null; public Form5() { InitializeComponent(); } private void button1_Click(object sender, EventArgs e) { this.printDocument1.DocumentName = this.filename; this.printDocument1.Print(); } private void printDocument1_BeginPrint(object sender, System.Drawing.Printing.PrintEventArgs e) { printerfont = new Font("Lucida Console", 72); } private void printDocument1_EndPrint(object sender, System.Drawing.Printing.PrintEventArgs e) { printerfont.Dispose(); printerfont = null; } private void printDocument1_PrintPage(object sender, System.Drawing.Printing.PrintPageEventArgs e) { Graphics g = e.Graphics; g.DrawString("hello,/nPrinter", printerfont, Brushes.Black, 0, 0); } } }
願望本文所述對年夜家的C#法式設計有所贊助。