TextBox.CharacterCasing Свойство
Определение
Важно!
Некоторые сведения относятся к предварительной версии продукта, в которую до выпуска могут быть внесены существенные изменения. Майкрософт не предоставляет никаких гарантий, явных или подразумеваемых, относительно приведенных здесь сведений.
Возвращает или задает, изменяет ли TextBox элемент управления регистр символов по мере их ввода.
public:
property System::Windows::Forms::CharacterCasing CharacterCasing { System::Windows::Forms::CharacterCasing get(); void set(System::Windows::Forms::CharacterCasing value); };
public System.Windows.Forms.CharacterCasing CharacterCasing { get; set; }
member this.CharacterCasing : System.Windows.Forms.CharacterCasing with get, set
Public Property CharacterCasing As CharacterCasing
Значение свойства
Одно из CharacterCasing значений перечисления, указывающее, изменяет ли TextBox элемент управления регистр символов. Значение по умолчанию — CharacterCasing.Normal.
Исключения
Значение, которое не находится в диапазоне допустимых значений перечисления, было назначено свойству.
Примеры
В следующем примере кода создается элемент управления, используемый TextBox для принятия пароля. В этом примере свойство используется CharacterCasing для изменения всех символов, введенных в строчный регистр, и MaxLength свойство, ограничивающее длину пароля до восьми символов. В этом примере также используется 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
Комментарии
Свойство можно использовать CharacterCasing для изменения регистра символов в соответствии с требованиями приложения. Например, можно изменить регистр всех символов, введенных в элемент управления, используемый для ввода пароля в TextBox верхний или нижний регистр, чтобы применить политику для паролей.