Gets or sets the character used to mask characters in a single-line text box control used to enter passwords.
[Visual Basic] Public Property PasswordChar As Char [C#] public char PasswordChar {get; set;} [C++] public: __property __wchar_t get_PasswordChar(); public: __property void set_PasswordChar(__wchar_t); [JScript] public function get PasswordChar() : Char; public function set PasswordChar(Char);
The character used to mask characters entered in a TextBox control. Set the value of this property to an empty string if you do not want the text box control to mask characters as they are typed. Empty by default.
If the Multiline property is set to true, setting the PasswordChar property will have no effect.
The following example creates a TextBox control that is used to accept a password. This example uses the CharacterCasing property to change all characters typed to uppercase and the MaxLength property to restrict the password length to eight characters. This example also uses the TextAlign property to center the password in the TextBox control.
[Visual Basic]
Public Sub CreatePasswordTextBox() ' Create an instance of the TextBox control. Dim Text1 as TextBox Set Text1 = New TextBox 'Text1.MaxLength = 8 ' Assign the asterisk to be the password character. Text1.PasswordChar = "*" ' Change all text entered to be lowercase. Text1.CharacterCasing = CharacterCasing.Upper ' Align the text in the center of the TextBox control. Text1.TextAlign = HorizontalAlignment.Center End Sub