TextBox.PasswordChar 속성
정의
중요
일부 정보는 릴리스되기 전에 상당 부분 수정될 수 있는 시험판 제품과 관련이 있습니다. Microsoft는 여기에 제공된 정보에 대해 어떠한 명시적이거나 묵시적인 보증도 하지 않습니다.
한 줄 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
속성 값
한 줄 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 . 설정true될 때마다 UseSystemPasswordChar 기본 시스템 암호 문자가 사용되고 설정된 PasswordChar 문자는 무시됩니다.
속성이 PasswordChar 설정되면 키보드를 사용하여 컨트롤에서 잘라내기 및 복사 작업을 수행할 수 없습니다.
중요합니다
TextBox 암호 모드에 있는 경우 ( UseSystemPasswordChar또는 ReadOnly 이)가 제한된 모드에 있기 때문PasswordChar입니다trueTextBox. 이 모드에서는 사용하지 ImeMode 않도록 설정되지만 현재 ImeMode 는 캐시되므로 제한이 없는 경우 TextBox 복원할 수 있습니다. 이 설정/해제 ReadOnly 는 일반적인 시나리오입니다.
ImeMode 컨트롤이 제한된 모드에 있는 동안에는 그림자가 표시됩니다. 디자이너 관점에서 ImeMode 표시된 값은 실제 값입니다.