A password box is a Win Forms text box that displays placeholder characters while a user types a string.
To create a password text box
The PasswordChar property specifies the character displayed in the text box. For example, if you want asterisks displayed in the password box, specify * for the PasswordChar property. Then, regardless of what character a user types in the text box, an asterisk is displayed.
The code below initializes a text box that will accept a string up to 14 characters long and display asterisks in place of the string. The InitializeMyControl
procedure will not execute automatically: it must be called.
[Visual Basic] Private Sub InitializeMyControl() With TextBox1 .Text = "" ' Set to no text. .PasswordChar = "*" ' asterisk .MaxLength = 14 ' After 14, the control beeps. End With End Sub [C#]
Controlling the Insertion Point in a TextBox Control | Creating a Read-Only Text Box | Putting Quotation Marks in a String Programmatically | Selecting Text Programmatically in the TextBox Control | Viewing Multiple Lines in the TextBox Control| TextBox Control