Gets or sets the character used to mask characters of a password in a single-line TextBox control.
Assembly: System.Windows.Forms (in System.Windows.Forms.dll)
The UseSystemPasswordChar property has precedence over the property. Whenever the UseSystemPasswordChar is set to true, the default system password character is used and any character set by is ignored.
When theproperty is set, cut and copy actions in the control using the keyboard cannot be performed.
When the TextBox is in password mode because , UseSystemPasswordChar, or ReadOnly is true, the TextBox is in restricted mode. In this mode, the ImeMode is disabled, but the current ImeMode is cached so that it can be restored if the TextBox ever becomes unrestricted. Toggling the ReadOnly is a common scenario. The ImeMode is shadowed while the control is in restricted mode. From the designer perspective, the ImeMode value shown is the actual value.
The following code example creates a TextBox control that is used to accept a password. This example uses the CharacterCasing property to change all characters typed to lowercase 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.
Public Sub CreateMyPasswordTextBox() ' Create an instance of the TextBox control. Dim textBox1 As New TextBox() ' Set the maximum length of text in the control to eight. textBox1.MaxLength = 8 ' Assign the asterisk to be the password character. textBox1.PasswordChar = "*"c ' Change all text entered to be lowercase. textBox1.CharacterCasing = CharacterCasing.Lower ' Align the text in the center of the TextBox control. textBox1.TextAlign = HorizontalAlignment.Center End Sub
Available since 1.1