|
-
May 13th, 2004, 03:23 PM
#1
Thread Starter
Addicted Member
Print Text in Picturebox
How would I print text in a picturebox? In vb6 it is pic1.print (I believe). Thanks.
-
May 14th, 2004, 07:02 AM
#2
Addicted Member
Do you want to print the contents of the picture box??? ;\
Here is an example if you do.
Code:
private Image img;
private void button1_Click(object sender, System.EventArgs e)
{
img = pictureBox1.Image;
PrintDocument pr = new PrintDocument();
pr.PrintPage += new PrintPageEventHandler(this.PrintEX);
Margins margins = new Margins(0,0,0,0);
pr.DefaultPageSettings.Margins = margins;
pr.Print();
}
void PrintEX(object sender, PrintPageEventArgs ppea)
{
RectangleF rect;
rect = ppea.Graphics.VisibleClipBounds;
float width, height, scale;
width = img.Width;
height = img.Height;
scale = (float)((float)rect.Width / (float)width);
ppea.Graphics.DrawImage(img, 0,0, width * scale,height* scale);
}
-
May 14th, 2004, 08:14 AM
#3
Thread Starter
Addicted Member
No, I do not want to print the image in the PictureBox. I want to print "hello world" to the picture box. I want text in a picture box. I hope that is clearer. Thanks for your help.
-
May 14th, 2004, 09:57 AM
#4
Addicted Member
-
May 14th, 2004, 10:03 AM
#5
Thread Starter
Addicted Member
That looks like what I want. Can you convert that into C# Thanks for all of your help.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|