开发者

printing content of a picturebox

开发者 https://www.devze.com 2023-03-03 08:11 出处:网络
HI all, I have a picture box in my C# WinForms application which is sized 800x800. I want to print the content of this picture box using the following code but it does not do anything at all (just sh

HI all,

I have a picture box in my C# WinForms application which is sized 800x800. I want to print the content of this picture box using the following code but it does not do anything at all (just shows the print dialog and when I click on PRINT in the dialog i开发者_如何学Got doe nothing too. What's wrong?

    private void menuFilePrint_Click(object sender, EventArgs e)
    {
        printDocument.OriginAtMargins = true;
        printDocument.DocumentName = "TEST IMAGE PRINTING";

        printDialog.Document = printDocument;
        printDialog.ShowDialog();
    }

    private void printDocument_PrintPage(object sender, PrintPageEventArgs e)
    {
        e.Graphics.DrawImage(curveBox.Image, 0, 0);
    }


You didn't instruct the printDocument to print:

if(printDialog.ShowDialog() == DialogResult.OK)
    printDocument.Print();

the printDialog is used to set printing settings.


Without this command "printDocument1.Print();" Nothing will work.

0

精彩评论

暂无评论...
验证码 换一张
取 消