I've a textbox in my windows application. It allows only alphabets and digits. I want when ever I type any alphabet, it should be converted to uppercase.How can I do that and in which event? I've used str.ToUpper() but the cursor is shifting to the beginning of the string. Please give me solution.
To use a keyboard shortcut to change between lowercase, UPPERCASE, and Capitalize Each Word, select the text and press SHIFT + F3 until the case you want is applied.
Program to convert the uppercase string into lowercase using the strlwr() function. Strlwr() function: The strlwr() function is a predefined function of the string library used to convert the uppercase string into the lowercase by passing the given string as an argument to return the lowercase string.
In C#, ToUpper() is a string method. It converts every characters to uppercase (if there is an uppercase version). If a character does not have an uppercase equivalent, it remains unchanged. For example, special symbols remain unchanged.
You just need to change CharacterChasing property to Upper
.
textBox1.CharacterCasing = CharacterCasing.Upper
Why to reinvent the wheel, just set 'CharacterCasing' property of textBox to 'Upper'. You don't need to write any code.
In case of masked textbox, you can use '>' (in mask property) to make following characters uppercase. e.g. For a input alphanumeric string (A-Z, 0-9) of length eight, use mask '>AAAAAAAA'. To restrict to letters only (A-Z), use '>LLLLLLLL'.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With