Partager via


TextBox.CharacterCasing Propriété

Définition

Obtient ou définit si le TextBox contrôle modifie la casse des caractères au fur et à mesure qu’ils sont tapés.

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

Valeur de propriété

Une des valeurs d’énumération CharacterCasing qui spécifie si le TextBox contrôle modifie le cas des caractères. La valeur par défaut est CharacterCasing.Normal.

Exceptions

Valeur qui ne se trouve pas dans la plage de valeurs valides pour l’énumération a été affectée à la propriété.

Exemples

L’exemple de code suivant crée un TextBox contrôle utilisé pour accepter un mot de passe. Cet exemple utilise la CharacterCasing propriété pour modifier tous les caractères typés en minuscules et la MaxLength propriété pour limiter la longueur du mot de passe à huit caractères. Cet exemple utilise également la TextAlign propriété pour centrer le mot de passe dans le TextBox contrôle.

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

Remarques

Vous pouvez utiliser la CharacterCasing propriété pour modifier la casse des caractères selon les besoins de votre application. Par exemple, vous pouvez modifier le cas de tous les caractères entrés dans un TextBox contrôle utilisé pour l’entrée de mot de passe en majuscules ou en minuscules pour appliquer une stratégie pour les mots de passe.

S’applique à

Voir aussi