I'm currently making a login form to my program where I have a watermark for the two textboxes Email and Password.
When a textbox is empty, its watermark text will appear in it like "Enter email here" and "Enter password here".
My code so far is:
private void emailLogin_Leave(object sender, EventArgs e){
if (emailLogin.Text.Length == 0){
emailLogin.Text = "Email";
emailLogin.ForeColor = Color.Silver;
}
}
private void emailLogin_Enter(object sender, EventArgs e){
if (emailLogin.Text == "Email"){
emailLogin.Text = "";
emailLogin.ForeColor = Color.Black;
}
}
private void passwordLogin_Leave(object sender, EventArgs e){
if (passwordLogin.Text.Length == 0){
passwordLogin.Text = "Password";
passwordLogin.ForeColor = Color.Silver;
}
}
private void passwordLogin_Enter(object sender, EventArgs e){
if (passwordLogin.Text == "Password"){
passwordLogin.Text = "";
passwordLogin.ForeColor = Color.Black;
}
}
But now my problem is that I want to use password characters for the password. But I still want the watermark text to be in regular text. When I check to use a password char it turns my watermark into "**" instead of "Password". How can I fix that?
By the way, I don't want to use the "UseSystemPasswordChar" (those dots). I want to use "PasswordChar" and use asterisks (*) as password chars.