弹框打印
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);