I have 6 Textbox in a registration form with some preset text.
When I click in the Textbox for Name then preset text Enter your full name should disappear...If I then click on the Textbox for Email without writing anything in Name Textbox, then Enter your full name should appear again. This event should happen for all my Textbox, but their should be different text in each Textbox...Not Enter your full name in all of them. Can someone please help me with this?
The code I have right now makes it possible to clear the Textbox as I click on them, using GotFocus event.
private void textBox1_GotFocus(Object sender, EventArgs e)
{
textBox1.Clear();
}
In the textboxes, I have preset text....I want that exact preset text for each textbox to come back whenever I am clicking outside that Textbox.
I've heard something about a "Placeholder" ?
Here's how it looks now with an extra constructor. I can't figure out what I'm doing wrong?
public partial class CustomTextbox : TextBox
{
private const string _text = @"Enter your full name";
private bool _isEmpty = true;
public CustomTextbox()
{
base.ForeColor = SystemColors.GrayText;
Text = _text;
Leave += LeaveTextBox;
Enter += EnterTextBox;
TextChanged += TextChangedTextBox;
}
public CustomTextbox(string tempText)
{
base.ForeColor = SystemColors.GrayText;
Text = tempText;
Leave += LeaveTextBox;
Enter += EnterTextBox;
TextChanged += TextChangedTextBox;
}