TextBox.CharacterCasing Propriedade
Definição
Importante
Algumas informações dizem respeito a um produto pré-lançado que pode ser substancialmente modificado antes de ser lançado. A Microsoft não faz garantias, de forma expressa ou implícita, em relação à informação aqui apresentada.
Obtém ou define se o TextBox controlo modifica o caso dos caracteres à medida que são digitados.
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
Valor de Propriedade
Um dos CharacterCasing valores de enumeração que especifica se o TextBox controlo modifica o caso dos caracteres. A predefinição é CharacterCasing.Normal.
Exceções
Um valor que não está dentro do intervalo de valores válidos para a enumeração foi atribuído à propriedade.
Exemplos
O seguinte exemplo de código cria um TextBox controlo que é usado para aceitar uma palavra-passe. Este exemplo usa a CharacterCasing propriedade para alterar todos os caracteres digitados para minúsculas e a MaxLength propriedade para restringir o comprimento da palavra-passe a oito caracteres. Este exemplo também usa a TextAlign propriedade para centralizar a palavra-passe no TextBox controlo.
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
Observações
Pode usar a CharacterCasing propriedade para alterar o caso dos caracteres conforme exigido pela sua aplicação. Por exemplo, pode alterar a maiúscula de todos os caracteres inseridos num TextBox controlo usado para introdução de palavra-passe para maiúsculas ou minúsculas para impor uma política para palavras-passe.