How to hide a password in C #

3

I want to hide my password.

What I want to happen is that as long as I type the "*" is shown instead of the characters, the problem is that this happens only when I click the "Log in" button.

Yes, I know this happens because the commands are inside the button's event block, but how do I get them out of there?

I tried to do out of the event but I can not use the text box, what can I do?

    
asked by anonymous 31.05.2017 / 22:01

2 answers

4

Just set the < strong> PasswordChar of the TextBox, you do not need any extra events.

txtSenha.PasswordChar = '*';
    
31.05.2017 / 22:09
4

The TextBox fields have a property called UseSystemPasswordChar , change it to true .

    
31.05.2017 / 22:11