Print & Print Preview a Bitmap in c#

2019-08-18 01:34发布

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条回答
做个烂人
2楼-- · 2019-08-18 02:25

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.

查看更多
登录 后发表回答