I want my TextBox to make the text I enter as Sentence Case(ProperCase).. but I don’t want to write any code in an event like Lost Focus or KeyPress.
Just by default, whenever a user enters or types in a textbox the first letter of every word should automatically be converted into UpperCase.
I don’t know of a way to do this in WinForms without putting some code in an event. The
CharacterCasingproperty of a TextBox allows you to force all characters entered to upper or lower case, but not to do Proper Casing. Incidentally, it’s a single line of code to do it in an event:A more generic handler for doing this across multiple textboxes involves attaching a number of events to the same code:
In ASP.NET, you can do this without code; there’s a CSS property called
text-transform, one of the values for this property iscapitalize. When applied to a text input element, it makes the first letter of each word uppercase.