彈框列印
PrintDialog pd = new PrintDialog();
pd.ShowDialog();
//↓第一個參數是StackPanel控件裡面放一個label放列印的文字
pd.PrintVisual(spdaying, "學生資訊");
直接列印
using System.Drawing;
using System.Drawing.Printing;
PrintDocument pd = new PrintDocument();
//+=的事件 可以按Tab按鈕快速建立代碼!!!
pd.PrintPage += pd_PrintPage;
pd.Print();
void pd_PrintPage(object sender, PrintPageEventArgs e)
{
string info = "列印内容
";
//e.圖表算法.繪制字元串,Brushes刷子
e.Graphics.DrawString(info, new Font("正常", 15),System.Drawing.Brushes.Black,0,0);
}
//列印條形碼
Bitmap bp = new Bitmap("1.jpg");
e.Graphics.DrawImage(bp, 0, 0,210,100);