C#基本打印事件用法實例
更新時間:2015年06月13日 09:17:13 作者:zhuzhao
這篇文章主要介紹了C#基本打印事件用法,實例分析了C#中print打印及DrawString文本字符串繪制等相關技巧,需要的朋友可以參考下
本文實例講述了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#程序設計有所幫助。
相關文章
C#中IEnumerable接口介紹并實現(xiàn)自定義集合
這篇文章介紹了C#中IEnumerable接口并實現(xiàn)自定義集合,文中通過示例代碼介紹的非常詳細。對大家的學習或工作具有一定的參考借鑒價值,需要的朋友可以參考下2022-04-04
c#linq里的Skip和Take實現(xiàn)分頁或遍歷
LINQ的優(yōu)勢在于它提供了一種直觀、類型安全的方式來操作各種類型的數(shù)據(jù),查詢常需要獲取一部分數(shù)據(jù),為了實現(xiàn)這一功能,LINQ提供了Take?和Skip運算符,Take運算符用于從一個序列中返回指定個數(shù)的元素,Skip運算符用于從一個序列中跳過指定個數(shù)的元素2024-01-01
C#實現(xiàn)的ACCESS數(shù)據(jù)庫操作類完整實例
這篇文章主要介紹了C#實現(xiàn)的ACCESS數(shù)據(jù)庫操作類,結合完整實例形式分析了C#針對access數(shù)據(jù)庫增刪改查、事務、結果處理等相關操作技巧,需要的朋友可以參考下2017-05-05

