So I have a text box and I have PasswordChar set to true so that when someone clicks the text box it has dots. But what I'm trying to do is make it where it has displaying text on the textbox that says "Password" and when someone clicks the text box the displaying text goes away. http://prntscr.com/je8dnz
Asked
Active
Viewed 208 times
0
-
Look into the Enter event! – TaW May 05 '18 at 22:39
-
Your image suggests you want to use something that is called `Cue Banner`. Take a look at this answer: https://stackoverflow.com/a/4902969/9365244 – JayV May 05 '18 at 23:03
2 Answers
2
I am assuming your TextBox's name is textBox1
Anyways, I recommend to look into Events
C# has the very nice Enter event which fulfills exactly what you are asking for.
public Form1()
{
InitializeComponent();
textBox1.Enter += TextBox1_Enter;
}
private void TextBox1_Enter(object sender, EventArgs e)
{
textBox1.Text = String.Empty;
textBox1.PasswordChar = '*';
}

Arnoldo Sontag
- 48
- 1
- 4
0
As you have an OnClick event you can do something similar to the following:
Textbox.Text = "";
Textbox.PasswordChar = '*';
The first line just removed the default text in the box and the second should show any input characters as stars.
Hope it helps.

Shadow
- 143
- 8