Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Printing from the PictureBox Control

Status
Not open for further replies.
Jun 17, 2004
73
US
Is it possible to print the image in a PictureBox?

/cry
/help

[viking2]
LVL 60 ROGUE
 
Here giving a code to print the imagebox image on click of a button. You can modify the code as per your requirement.
Code:
private void button1_Click(Object sender, EventArgs e)
        {
            PrintDocument tmpDoc = new PrintDocument();
            tmpDoc.PrintPage += new PrintPageEventHandler(Tmpdoc_Print);
            PrintPreviewDialog tmpPpd = new PrintPreviewDialog();
            tmpPpd.Document=tmpDoc;
            tmpPpd.ShowDialog();
        }
        private void Tmpdoc_Print( Object sender, PrintPageEventArgs e)
        {
            e.Graphics.DrawImage(pictureBox1.Image, 0, 0);
        }

Sharing the best from my side...

--Prashant--
 
Sorry forgot to give this!
You need to import:
Code:
using System.Drawing.Printing;

Sharing the best from my side...

--Prashant--
 
Thanks for your response.

For some reason when the Print Preview opens it says "Document does not contain any pages."

I am using a multi-page tiff so this is kind of strange.

Going to keep playing with it, thanks for pointing me in the right direction.



/cry
/help

[viking2]
LVL 60 ROGUE
 
nevermind "interface errror"

that old problem between the chair and the keyboard. thanks a bunch.

/cry
/help

[viking2]
LVL 60 ROGUE
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top