CharacterCasing 列挙体
TextBox コントロール内の文字を大文字と小文字のどちらで表示するかを指定します。
<Serializable>
Public Enum CharacterCasing
[C#]
[Serializable]
public enum CharacterCasing
[C++]
[Serializable]
__value public enum CharacterCasing
[JScript]
public
Serializable
enum CharacterCasing
解説
この列挙体のメンバを使用して、 TextBox コントロールの CharacterCasing プロパティの値を設定します。
メンバ
メンバ名 | 説明 |
---|---|
Lower | すべての文字を小文字に変換します。 |
Normal | 大文字と小文字はそのまま表示されます。 |
Upper | すべての文字を大文字に変換します。 |
使用例
パスワードを受け入れるために使用される TextBox コントロールを作成する例を次に示します。この例では、 CharacterCasing プロパティを使用して、入力されたすべての文字を大文字に変更します。また、 MaxLength プロパティを使用して、パスワード長を 8 文字に制限します。この例では、 TextAlign プロパティも使用して、 TextBox コントロールの中央にパスワードを配置します。
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
[C#]
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;
}
[C++]
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;
}
[JScript]
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;
}
必要条件
名前空間: System.Windows.Forms
プラットフォーム: Windows 98, Windows NT 4.0, Windows Millennium Edition, Windows 2000, Windows XP Home Edition, Windows XP Professional, Windows Server 2003 ファミリ
アセンブリ: System.Windows.Forms (System.Windows.Forms.dll 内)