Print & Print Preview a Bitmap in c#

本小妞迷上赌 提交于 2019-12-12 02:10:03

问题


I have made a program that draws on a image on a picturebox and now i want to print and print preview this, but don't know how. Please Help,

Thanks

EDIT I have tried using print and print preview dialogs but don't know how to work them properly to print and show the contents of a picturebox and its image


回答1:


Drop a PrintDocument on your form. You'll want a PrintPreviewDialog and PrintDialog as well. Set the dialogs' Document property to the PrintDocument. Implement the PrintPage event handler for it, could be a simple as:

    private void printDocument1_PrintPage(object sender, System.Drawing.Printing.PrintPageEventArgs e) {
        e.Graphics.DrawImage(pictureBox1.Image, 0, 0);
    }

And add buttons or menu items to call the dialogs' ShowDialog() method.



来源:https://stackoverflow.com/questions/4246905/print-print-preview-a-bitmap-in-c-sharp

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!