Visual C#.NET:
private void tbAddress_GotFocus()
{
tbAddress.Text = "";
}
private void tbAddress_LostFocus()
{
if (tbAddress.Text == "") { tbAddress.Text = "Email Address"; }
}
So, I’m trying to use that code to make it so there is text in a (Windows Forms) textbox, and then when the textbox gets focus (when the user clicks inside of it), the text disappears. That way it looks like a form with the label inside the textbox.
So, why doesn’t that code work, or is there a better way to do it?
Here’s a tutorial on how to do watermarks in textboxes.
http://vidmar.net/weblog/archive/2008/11/05/watermarked-textbox-in-windows-forms-on-.net.aspx