TextBox.CharacterCasing Properti
Definisi
Penting
Beberapa informasi terkait produk prarilis yang dapat diubah secara signifikan sebelum dirilis. Microsoft tidak memberikan jaminan, tersirat maupun tersurat, sehubungan dengan informasi yang diberikan di sini.
Mendapatkan atau mengatur apakah TextBox kontrol memodifikasi kasus karakter saat diketik.
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
Nilai Properti
Salah CharacterCasing satu nilai enumerasi yang menentukan apakah TextBox kontrol memodifikasi kasus karakter. Defaultnya adalah CharacterCasing.Normal.
Pengecualian
Nilai yang tidak berada dalam rentang nilai yang valid untuk enumerasi ditetapkan ke properti .
Contoh
Contoh kode berikut membuat TextBox kontrol yang digunakan untuk menerima kata sandi. Contoh ini menggunakan properti untuk mengubah semua karakter yang CharacterCasing ditik menjadi huruf kecil, dan MaxLength properti untuk membatasi panjang kata sandi menjadi delapan karakter. Contoh ini juga menggunakan properti untuk mempusatkan TextAlign kata sandi dalam TextBox kontrol.
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
Keterangan
Anda dapat menggunakan CharacterCasing properti untuk mengubah kasus karakter seperti yang diperlukan oleh aplikasi Anda. Misalnya, Anda dapat mengubah kasus semua karakter yang dimasukkan dalam kontrol yang TextBox digunakan untuk entri kata sandi menjadi huruf besar atau kecil untuk memberlakukan kebijakan untuk kata sandi.