Click here to Skip to main content
14,932,329 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
I searched everywhere on the internet looking for C# source code that how i can put text on picturebox with mouse click.? i mean i want to write text in textbox and choose font/color/size and when click everywhere on picturebox can see text on that. is there any simple code?! Thanks

What I have tried:

Updated 12-Dec-20 19:57pm
BillWoodruff 13-Dec-20 9:56am
You've only tried "nothing" ten times, and you expect results ?
dandy72 13-Dec-20 13:02pm
Yeah, things only start behaving differently after the 17th time, duh!
W Balboos, GHB 13-Dec-20 16:46pm
I think his problem is that 'Nothing" is case sensitive.

1 solution

Basically, you don't: you write onto the image that the picture box displays.
Handle the PictureBox.Click event and you get the X and Y position from the EventArgs that the handler is provided with.
Then get the image, and draw your text onto it:
using (Graphics g = Graphics.FromImage( MyPictureBox.Image))
   graphicImage.DrawString(theText, theFont, theBrush, theLocation);

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900