CharacterCasing 枚举

定义

指定 TextBox 控件中字符的大小写。Specifies the case of characters in a TextBox control.

public enum class CharacterCasing
public enum CharacterCasing
type CharacterCasing = 
Public Enum CharacterCasing
继承
CharacterCasing

字段

Lower 2

将所有字符都转换为小写。Converts all characters to lowercase.

Normal 0

字符大小写保持不变。The case of characters is left unchanged.

Upper 1

将所有字符都转换为大写。Converts all characters to uppercase.

示例

下面的示例创建一个TextBox用于接受密码的控件。The following example creates a TextBox control that is used to accept a password. 此示例使用CharacterCasing属性将键入的所有字符更改为大写MaxLength , 并使用属性将密码长度限制为8个字符。This example uses the CharacterCasing property to change all characters typed to uppercase and the MaxLength property to restrict the password length to eight characters. 此示例还使用TextAlign属性使密码TextBox在控件中居中。This example also uses the TextAlign property to center the password in the TextBox control.

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

注解

使用此枚举的成员设置CharacterCasing TextBox控件的属性的值。Use the members of this enumeration to set the value of the CharacterCasing property of the TextBox control.

适用于