Reputation: 147
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
Upvotes: 0
Views: 713
Reputation: 48
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 = '*';
}
Upvotes: 2
Reputation: 143
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.
Upvotes: 0