Q: I have a simple form with a few labels and text boxes on it that I am planning to use for data entry. I have default text set for each text box, but I would like that text to be cleared and the text box to be empty as soon as the text box gets focus (tabbed into or clicked in). Also, if possible, I would like that default text to remain in the text box after it loses focus IF the user did not enter any text in the box. Thanks for any and all help!!
A: we'll you can use the TextBox ENTER and LEAVE event heres what you should do: 1. Click on your text box and goto properties, then select EVENTS 2. double click on the "Enter" event and insert the following code (this is for clearing the textbox upon focus ) private void txtName_Enter(object sender, EventArgs e) { txtName.Text = ""; } 3. To set Text property to default values if it is empty, goto back to TextBox Events, and double-click "Leave", and insert the following code. private void txtName_Leave(object sender, EventArgs e) { if( txtName.Text == "" ) { txtName.Text = "default Text" ; } } hope this helps.