Results 1 to 5 of 5

Thread: Print Text in Picturebox

  1. #1

    Thread Starter
    Addicted Member jordan23's Avatar
    Join Date
    Dec 2002
    Posts
    166

    Print Text in Picturebox

    How would I print text in a picturebox? In vb6 it is pic1.print (I believe). Thanks.

  2. #2
    Addicted Member
    Join Date
    Jun 2003
    Location
    Birmingham, AL
    Posts
    188
    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);
    }

  3. #3

    Thread Starter
    Addicted Member jordan23's Avatar
    Join Date
    Dec 2002
    Posts
    166
    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.

  4. #4
    Addicted Member
    Join Date
    Jun 2003
    Location
    Birmingham, AL
    Posts
    188
    oh ok. See if this helps.

    http://www.dotnetforums.net/t74823.html

  5. #5

    Thread Starter
    Addicted Member jordan23's Avatar
    Join Date
    Dec 2002
    Posts
    166
    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
  •  



Click Here to Expand Forum to Full Width