Make TextBoxes automatically convert case in C#

[example]

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 Example   Follow me on Twitter   RSS feed   Donate




This entry was posted in controls, strings, user interface and tagged , , , , , , , , , , , , . Bookmark the permalink.

Leave a Reply

Your email address will not be published. Required fields are marked *