TextBox.PasswordChar 속성

정의

한 줄만 입력할 수 있는 TextBox 컨트롤에서 암호 문자를 마스킹하는 데 사용되는 문자를 가져오거나 설정합니다.

public:
 property char PasswordChar { char get(); void set(char value); };
public char PasswordChar { get; set; }
member this.PasswordChar : char with get, set
Public Property PasswordChar As Char

속성 값

Char

한 줄만 입력할 수 있는 TextBox 컨트롤에 입력한 문자를 마스킹하는 데 사용되는 문자입니다. 컨트롤에서 문자를 입력할 때 마스킹하지 않으려면 이 속성의 값을 '0'(U+0000)으로 설정합니다. 기본값은 '0'(U+0000)입니다.

예제

다음 코드 예제에서는 암호를 수락하는 데 사용되는 컨트롤을 만듭니다 TextBox . 이 예제에서는 속성을 사용하여 소문자로 입력된 모든 문자를 변경하고 MaxLength 이 속성을 사용하여 CharacterCasing 암호 길이를 8자로 제한합니다. 또한이 예제에서는 합니다 TextAlign 속성에 암호를 가운데를 TextBox 컨트롤입니다.

public:
   void CreateMyPasswordTextBox()
   {
      // Create an instance of the TextBox control.
      TextBox^ textBox1 = gcnew 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 = '*';
      // 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;
   }
public void CreateMyPasswordTextBox()
 {
    // Create an instance of the TextBox control.
    TextBox textBox1 = 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 = '*';
    // 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;
 }
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

설명

속성 UseSystemPasswordChar 이 속성보다 우선합니다 PasswordChar . 설정trueUseSystemPasswordChar 때마다 기본 시스템 암호 문자가 사용되고 설정된 PasswordChar 문자는 무시됩니다.

속성이 PasswordChar 설정되면 키보드를 사용하여 컨트롤에서 잘라내기 및 복사 작업을 수행할 수 없습니다.

중요

TextBox 암호 모드에 있는 경우 , UseSystemPasswordChar또는 ReadOnly 암호가 제한된 모드에 있기 때문PasswordChar입니다trueTextBox. 이 모드에서는 비활성화 ImeMode 되지만 현재 ImeMode 는 캐시되므로 제한되지 않는 경우 TextBox 복원할 수 있습니다. 이 설정은 ReadOnly 일반적인 시나리오입니다. ImeMode 컨트롤이 제한된 모드에 있는 동안에는 그림자가 표시됩니다. 디자이너 관점에서 ImeMode 표시된 값은 실제 값입니다.

적용 대상