1.使用的是PrintDocument控件,在工具箱 ,将其托到窗体上;
2.
1 private void btnprint_Click(object sender, EventArgs e)
2 {
3 printDocument1.PrinterSettings.PrinterName = printerComboBox.SelectedItem.ToString();//给出打印机名称,我这里是获取本机的打印机(http://www.cnblogs.com/bonnie-w/p/7895474.html)
4 printDocument1.PrinterSettings.Copies = 1;
5 printDocument1.Print();
6 }
7 //通过GDI+绘制打印文档
8 private void printDocument1_PrintPage(object sender, System.Drawing.Printing.PrintPageEventArgs e)
9 {
10 Font FoolterWorkCode = new Font("宋体", 9F, FontStyle.Bold, GraphicsUnit.Point, ((byte)(134)));
11 e.Graphics.DrawString("/*---打印内容---*/", FoolterWorkCode, Brushes.Black, 0, 0);
12 e.Graphics.DrawImage(barcode.Image, 5, 0);//也可打印生成的图片
13 }