zoukankan      html  css  js  c++  java
  • c#如何打印picturebox里的图片,winform怎样打印picturebox里的图片

    c#如何打印picturebox里的图片,winform怎样打印picturebox里的图片

    第一步:

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

     private void 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事件:
     private void printDocument1_PrintPage(object sender, System.Drawing.Printing.PrintPageEventArgs e)
            {
                e.Graphics.DrawImage(pictureBox1.Image,
    20, 20);
            }


  • 相关阅读:
    152. 乘积最大子数组
    Java中wait和sleep方法的区别(美团面试面到了)
    HashMap1.7与1.8的区别
    类型转换
    Goland控制台中文乱码
    Spring 之 IOC
    Spring定时任务/Cron
    Mybatis 不加载xml文件
    MySQL :=和=的区别
    Go 第一个程序
  • 原文地址:https://www.cnblogs.com/hfzsjz/p/1809241.html
Copyright © 2011-2022 走看看