Title: Make TextBoxes automatically convert case in C#
It's actually quite easy to make a TextBox convert case in .NET. Simply set the TextBox control's CharacterCasing property to Lower or Upper. Then the control automatically converts alphabetic characters into the correct case.
You can do this at design time, although in this example I set the properties in the following code so they are easy to see.
private void Form1_Load(object sender, EventArgs e)
{
txtLowerCase.CharacterCasing = CharacterCasing.Lower;
txtUpperCase.CharacterCasing = CharacterCasing.Upper;
}
That's all there is to making a TextBox convert case, at least to upper and lower case. My next two posts will look at proper case, where each word in a phrase is capitalized.
Download the example to experiment with it and to see additional details.
|