|
-
Sep 6th, 2009, 11:01 AM
#1
Thread Starter
Hyperactive Member
Trouble with Graphics.drawstring
Having some trouble, need help.
So, what I've got is a picturebox and a textbox, I got some code to put text into a picturebox so I could better understand how it works, but what I don't understand is how to put the text on top of the image that is in the picturebox, can anyone tell me how to do that?
Here's the code
vb Code:
Dim Graph As Graphics
Dim Drawbitmap As Bitmap
Dim Brush As New Drawing.SolidBrush(Color.Black)
private sub textbox1_text changed( byval sender as blah blah blah...)
Drawbitmap = New Bitmap(PictureBox1.Width, PictureBox1.Height)
Graph = Graphics.FromImage(Drawbitmap)
PictureBox1.Image = Drawbitmap
Graph.SmoothingMode = Drawing2D.SmoothingMode.HighQuality
Graph.DrawString(TextBox1.Text, TextBox1.Font, Brush, PictureBox1.Location)
end sub
-
Sep 6th, 2009, 11:25 AM
#2
Re: Trouble with Graphics.drawstring
If you want the text on the Image that's in the PictureBox then you have to create your Graphics object from the Image that's in the PictureBox, not from some new Image that you just created. If you want to write on a book then you write on that book. You don't go and get a new book and write on that. The same goes here. These two lines are the issue:
Code:
Drawbitmap = New Bitmap(PictureBox1.Width, PictureBox1.Height)
Graph = Graphics.FromImage(Drawbitmap)
If you want to draw on an existing Image then don't create a new Image.
-
Sep 6th, 2009, 11:33 AM
#3
Thread Starter
Hyperactive Member
Re: Trouble with Graphics.drawstring
-
Sep 6th, 2009, 11:36 AM
#4
Re: Trouble with Graphics.drawstring
How do you normally access the Image in the PictureBox? How do you display an Image in the PictureBox in the first place?
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
|