TextBox.CharacterCasing Egenskap

Definition

Hämtar eller anger om TextBox kontrollen ändrar teckenfallet när de skrivs.

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

Egenskapsvärde

Ett av uppräkningsvärdena CharacterCasing som anger om TextBox kontrollen ändrar teckenfallet. Standardvärdet är CharacterCasing.Normal.

Undantag

Ett värde som inte ligger inom intervallet med giltiga värden för uppräkningen tilldelades egenskapen.

Exempel

I följande kodexempel skapas en TextBox kontroll som används för att acceptera ett lösenord. I det CharacterCasing här exemplet används egenskapen för att ändra alla tecken som skrivs till gemener MaxLength och egenskapen för att begränsa lösenordslängden till åtta tecken. I det här exemplet används TextAlign även egenskapen för att centrera lösenordet i TextBox kontrollen.

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

Kommentarer

Du kan använda egenskapen CharacterCasing för att ändra teckenfallet enligt programmets krav. Du kan till exempel ändra skiftläget för alla tecken som anges i en TextBox kontroll som används för lösenordsinmatning till versaler eller gemener för att framtvinga en princip för lösenord.

Gäller för

Se även