Resolved c# hide password

c0stinha

New member
Joined
Jun 28, 2022
Messages
4
Programming Experience
Beginner
Hi guys, I'm new to c# and I'm trying to make a login scheme. I want to make it so that when you type the password that digits appear to hide the password.

This is the code I used but it didn't work...

----------------------------------------------------------------------------
private void textbox2_TextChanged(object sender, EventArgs e)
{
if (textbox2.Text == "Password")
{
textbox2.UseSystemPasswordChar = false;

}
else
textbox2.UseSystemPasswordChar = true;
}

-----------------------------------------------------------------------------

Can anyone help me please?
 
What behavior are you seeing?
When I write in the textbox of the Password it writes normally while it should be hidden by digits
 

Attachments

  • Screenshot_2.png
    Screenshot_2.png
    2.4 KB · Views: 14
My understanding of the use of UseSystemPasswordChar is that you set it to true or false before the textbox is first displayed and then just leave it alone. Or at least that what I used to do with the Win32 API equivalent. I've never tried flip-flopping it like you are trying to do.
 
My understanding of the use of UseSystemPasswordChar is that you set it to true or false before the textbox is first displayed and then just leave it alone. Or at least that what I used to do with the Win32 API equivalent. I've never tried flip-flopping it like you are trying to do.
Okok thanks for the concern anyway.
 
My understanding of the use of UseSystemPasswordChar is that you set it to true or false before the textbox is first displayed and then just leave it alone. Or at least that what I used to do with the Win32 API equivalent. I've never tried flip-flopping it like you are trying to do.
I just solved the problem!
thanks.
 
Glad you solved it. It may help the rest of the C# community if you share what you did so that when others run into the same problem, they can try your solution.
 
Back
Top Bottom