1,105,197 Community Members

How to Draw an Editable Text Box on top of a PictureBox in c#

Member Avatar
rainbow9
Newbie Poster
4 posts since Jul 2011
Reputation Points: 0 [?]
Q&As Helped to Solve: 0 [?]
Skill Endorsements: 0 [?]
 
0
 

I want to draw a editable TextBox on top of picture box and the user is allowed to enter text into this box.After entering text the text box should disappear and the text entered should be painted to the picture in the picture box.Please help me on this,I'am doing this in c#.

Member Avatar
manugm_1987
Junior Poster in Training
57 posts since Feb 2009
Reputation Points: 0 [?]
Q&As Helped to Solve: 1 [?]
Skill Endorsements: 0 [?]
 
0
 

Check for the keypress, when key is return then make textbox.visible property to false.

private void textBox1_KeyPress(object sender, KeyPressEventArgs e)
        {
            if (e.KeyChar == (char)13)
                textBox1.Visible = false;
        }

To Display text on picture box check this http://www.fordevs.com/2009/02/convert-text-to-image-using-c.html

Try this,

private void pictureBox1_Paint(object sender, PaintEventArgs e)
        {
            Font myfont = new Font("Arial", 14);
            e.Graphics.DrawString("Hello", myfont, Brushes.Green,new PointF());
        }
Member Avatar
rainbow9
Newbie Poster
4 posts since Jul 2011
Reputation Points: 0 [?]
Q&As Helped to Solve: 0 [?]
Skill Endorsements: 0 [?]
 
0
 

Thanks but,Im talking about painting the textbox itself on the picture at a position on mouse click ,not using drawstring method.

Member Avatar
ddanbe
Posting Expert
5,335 posts since Oct 2008
Reputation Points: 2,054 [?]
Q&As Helped to Solve: 904 [?]
Skill Endorsements: 46 [?]
Featured
 
0
 

Do you mean something like this? (Coords of Location are not correct)

public partial class Form1 : Form
    {
        private TextBox PTB
        public Form1()
        {
            InitializeComponent();
        }

        private void pictureBox1_Click(object sender, EventArgs e)
        {
            PTB = new TextBox();
            PTB.Location = new System.Drawing.Point(56, 193);
            PTB.Name = "textBox1";
            PTB.Size = new System.Drawing.Size(100, 20);
        }
    }
Member Avatar
rainbow9
Newbie Poster
4 posts since Jul 2011
Reputation Points: 0 [?]
Q&As Helped to Solve: 0 [?]
Skill Endorsements: 0 [?]
 
0
 

yes,Thanks

Member Avatar
ddanbe
Posting Expert
5,335 posts since Oct 2008
Reputation Points: 2,054 [?]
Q&As Helped to Solve: 904 [?]
Skill Endorsements: 46 [?]
Featured
 
0
 

If you consider this solved, why don't you mark it as such?

Member Avatar
rainbow9
Newbie Poster
4 posts since Jul 2011
Reputation Points: 0 [?]
Q&As Helped to Solve: 0 [?]
Skill Endorsements: 0 [?]
 
0
 

The Code is not working.

You
This article has been dead for over three months: Start a new discussion instead
Post:
Start New Discussion
View similar articles that have also been tagged: