第一步:

拖一个printDocument控件到界面。
打印按钮的代码:
C# CODE:

 privatevoid button1_Click(object sender, EventArgs e)//执行打印
        {
            PrintDialog MyPrintDg
=new PrintDialog();
            MyPrintDg.Document
= printDocument1;
           
if (MyPrintDg.ShowDialog() == DialogResult.OK) { try
                {
                    printDocument1.Print();
                }
               
catch
                {  
//停止打印
                    printDocument1.PrintController.OnEndPrint(printDocument1, new System.Drawing.Printing.PrintEventArgs());
                }
            }
        }

第2步:
设置printDocument控件的PrintPage事件:
 privatevoid printDocument1_PrintPage(object sender, System.Drawing.Printing.PrintPageEventArgs e)
        {
            e.Graphics.DrawImage(pictureBox1.Image,
20, 20);
        }

相关文章:

  • 2022-02-09
  • 2021-12-21
  • 2021-12-21
  • 2022-01-02
  • 2022-01-04
  • 2021-12-25
猜你喜欢
  • 2021-12-01
  • 2021-07-24
  • 2021-10-18
  • 2022-01-14
  • 2022-12-23
相关资源
相似解决方案