Search code examples
c#winformstextboxpasswordsmaskedtextbox

Password Character not working on System.Windows.Forms.TextBox


Thats it really..

I am using VS2008 Express.

All the samples say just to set the PasswordChar, but nothing gets masked.

I also tried setting the "UseSystemPasswordChar" = true.. no luck..

   // Set to no text.
   textBox1.Text = "";
   // The password character is an asterisk.
   textBox1.PasswordChar = '*';
   // The control will allow no more than 14 characters.
   textBox1.MaxLength = 14;

The reason I'm using a TextBox is because I want the user to be able to hit return and it submits the data. Its important to note I guess that I have MultiLine = true so that I can capture the return.

I can't seem to be able to capture a return with a maskedTextBox. All I get is a system beep.

a solution to either is fine for me!


Solution

  • If you read the documentation is says "If the Multiline property is set to true, setting the PasswordChar property has no visual effect."