Condividi tramite


TextBox.CharacterCasing Proprietà

Definizione

Ottiene o imposta un valore che indica se il TextBox controllo modifica le maiuscole e minuscole dei caratteri durante la digitazione.

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

Valore della proprietà

Uno dei valori di CharacterCasing enumerazione che specifica se il TextBox controllo modifica la distinzione tra maiuscole e minuscole. Il valore predefinito è CharacterCasing.Normal.

Eccezioni

Un valore non compreso nell'intervallo di valori validi per l'enumerazione è stato assegnato alla proprietà .

Esempio

Nell'esempio di codice seguente viene creato un TextBox controllo utilizzato per accettare una password. In questo esempio viene utilizzata la CharacterCasing proprietà per modificare tutti i caratteri digitati in lettere minuscole e la MaxLength proprietà per limitare la lunghezza della password a otto caratteri. In questo esempio viene usata anche la TextAlign proprietà per centrare la password nel TextBox controllo .

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

Commenti

È possibile usare la CharacterCasing proprietà per modificare la distinzione tra maiuscole e minuscole in base alle esigenze dell'applicazione. Ad esempio, è possibile modificare il caso di tutti i caratteri immessi in un TextBox controllo usato per la voce della password in lettere maiuscole o minuscole per applicare un criterio per le password.

Si applica a

Vedi anche