Click here to Skip to main content
15,889,992 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I want to change string lower to upper code given below:
C#
private void textBox1_TextChanged(object sender, TextChangedEventArgs e)
        {
           string str = textBox1.Text;
           textBox1.Text = str.ToUpper();
        }

for example-imran.It converts but in reverse i.e. NARMI.
Please help me!
Posted
Comments
Xeshan Ahmed 14-Oct-11 8:24am    
don't use text change event instead simply use Charactercasing property

Wel if it is not necessary to use event then simply go to properties of your text box and change CharacterCasing to Upper, now all input will be in upper case.
 
Share this answer
 
You have to set the cursor position to the end of the text like this:
C#
void textBox1_TextChanged(object sender, EventArgs e)
{
    textBox1.Text = textBox1.Text.ToUpper();
    textBox1.Select(textBox1.Text.Length, 0);
}


cheers
Andy
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900