Search code examples
maskedtextbox

MaskedTextBox with PasswordChar defined, how to get the displayed string value?


I have a MaskedTextBox with the PasswordChar defined so that relevant characters are not displayed raw but instead have the defined PasswordChar used instead. Just like a traditional password entry field, except I have a Mask defined so that not all the characters are turned into the PasswordChar.

I want to get the string that is actually being displayed. If I use the MaskedTextBox.Text property it gives me the raw string without substituting the PasswordChar setting. This is a problem as I want the string that has the PasswordChar values used. Any ideas?


Solution

  • maskedTextBox1.MaskedTextProvider.ToDisplayString()