Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to convert string to uppercase in windows textbox?

Tags:

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.

like image 384
Sukanya Avatar asked Apr 11 '12 10:04

Sukanya


People also ask

How do I make text uppercase in Windows?

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.

How do I convert a lowercase string to uppercase?

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.

How do you change to uppercase in C#?

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.


2 Answers

You just need to change CharacterChasing property to Upper.

textBox1.CharacterCasing = CharacterCasing.Upper 
like image 126
Ezio Auditore da Firenze Avatar answered Sep 21 '22 02:09

Ezio Auditore da Firenze


Why to reinvent the wheel, just set 'CharacterCasing' property of textBox to 'Upper'. You don't need to write any code.

Make letters in textBox uppercase

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'.

Make letters in maskedTextBox uppercase

like image 32
ePandit Avatar answered Sep 19 '22 02:09

ePandit