By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
432,569 Members | 1,386 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 432,569 IT Pros & Developers. It's quick & easy.

Hello! How to write text on textbox after the default text is clear?

P: 18
Hello! I'm using C# to doing my window application.

May I ask, how to write text on textbox after the default text is clear?

I have setted the default text in textbox, when a user click on it, the default text is automatically clear. I did that by using "Click" event. But then, how to enable the user write text in the textbox?


Expand|Select|Wrap|Line Numbers
  1. private void textBox_TextChanged(object sender, EventArgs e)
  2.         {
  3.             textBox.Text = string.Empty;
  4.         }

Can someone help me ?
Thanks!

By Aeris
Dec 12 '09 #1
Share this Question
Share on Google+
4 Replies


tlhintoq
Expert 2.5K+
P: 3,525
TIP: When you are writing your question, there is a button on the tool bar that wraps the [code] tags around your copy/pasted code. It helps a bunch. Its the button with a '#' on it. More on tags. They're cool. Check'em out.
Dec 12 '09 #2

tlhintoq
Expert 2.5K+
P: 3,525
But then, how to enable the user write text in the textbox?
You shouldn't have to do anything. A textbox by default allows input.

- UNLESS -

You have changed the ReadOnly property to true. If you did that, then change it back to false.
Dec 12 '09 #3

GaryTexmo
Expert 100+
P: 1,501
Actually, you've got the text changed event set to clear the contents (assuming the event name coincides with the event it's tied to), so every time you change the text it'll set it to empty. Judging from the other thread, you want the click event to set the text to empty, not the textchanged event :)
Dec 12 '09 #4

tlhintoq
Expert 2.5K+
P: 3,525
I was hoping the OP would catch that. Details, details, details. The devil is in the details and the ability to proofread one's own work.
Dec 12 '09 #5

Post your reply

Sign in to post your reply or Sign up for a free account.