TextBox.CharacterCasing-Eigenschaft

Ruft ab oder legt fest, ob das TextBox-Steuerelement die Groß-/Kleinschreibung eingegebener Zeichen ändert.

Namespace: System.Windows.Forms
Assembly: System.Windows.Forms (in system.windows.forms.dll)

Syntax

'Declaration
Public Property CharacterCasing As CharacterCasing
'Usage
Dim instance As TextBox
Dim value As CharacterCasing

value = instance.CharacterCasing

instance.CharacterCasing = value
public CharacterCasing CharacterCasing { get; set; }
public:
property CharacterCasing CharacterCasing {
    CharacterCasing get ();
    void set (CharacterCasing value);
}
/** @property */
public CharacterCasing get_CharacterCasing ()

/** @property */
public void set_CharacterCasing (CharacterCasing value)
public function get CharacterCasing () : CharacterCasing

public function set CharacterCasing (value : CharacterCasing)

Eigenschaftenwert

Einer der CharacterCasing-Enumerationswerte, der angibt, ob das TextBox-Steuerelement die Groß-/Kleinschreibung von Zeichen ändert. Der Standardwert ist CharacterCasing.Normal.

Ausnahmen

Ausnahmetyp Bedingung

InvalidEnumArgumentException

Der Eigenschaft wurde ein Wert außerhalb des gültigen Wertebereichs der Enumeration zugewiesen.

Hinweise

Mit der CharacterCasing-Eigenschaft kann die Groß-/Kleinschreibung von Zeichen nach Bedarf geändert werden. Sie können z. B. in einem für die Eingabe von Kennwörtern verwendeten TextBox-Steuerelement alle eingegebenen Zeichen in Groß- oder Kleinbuchstaben umwandeln, um eine bestimmte Richtlinie für Kennwörter umzusetzen.

Beispiel

Im folgenden Codebeispiel wird ein TextBox-Steuerelement erstellt, das zum Akzeptieren eines Kennworts verwendet wird. In diesem Beispiel werden mit der CharacterCasing-Eigenschaft alle Zeichen in Großbuchstaben umgewandelt, und mit der MaxLength-Eigenschaft wird die Kennwortlänge auf acht Zeichen beschränkt. In diesem Beispiel wird des Weiteren die TextAlign-Eigenschaft verwendet, um das Kennwort im TextBox-Steuerelement zu zentrieren.

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
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:
   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.set_MaxLength(8);
    // Assign the asterisk to be the password character.
    textBox1.set_PasswordChar('*');
    // Change all text entered to be lowercase.
    textBox1.set_CharacterCasing(CharacterCasing.Lower);
    // Align the text in the center of the TextBox control.
    textBox1.set_TextAlign(HorizontalAlignment.Center);
} //CreateMyPasswordTextBox
public function CreateMyPasswordTextBox()
 {
    // Create an instance of the TextBox control.
    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;
 }
 

Plattformen

Windows 98, Windows 2000 SP4, Windows CE, Windows Millennium Edition, Windows Mobile für Pocket PC, Windows Mobile für Smartphone, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition

.NET Framework unterstützt nicht alle Versionen sämtlicher Plattformen. Eine Liste der unterstützten Versionen finden Sie unter Systemanforderungen.

Versionsinformationen

.NET Framework

Unterstützt in: 2.0, 1.1, 1.0

Siehe auch

Referenz

TextBox-Klasse
TextBox-Member
System.Windows.Forms-Namespace
CharacterCasing-Enumeration