在text_change事件中将字符串从低位转换为高位 [英] convert string lower to upper on text_change event

查看:98
本文介绍了在text_change事件中将字符串从低位转换为高位的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想将字符串从低位改为高位代码,如下所示:

I want to change string lower to upper code given below:

private void textBox1_TextChanged(object sender, TextChangedEventArgs e)
        {
           string str = textBox1.Text;
           textBox1.Text = str.ToUpper();
        }


例如-imran.It会转换,但反过来,即NARMI.


for example-imran.It converts but in reverse i.e. NARMI.
Please help me!

推荐答案

好吧,如果不需要使用事件,那么只需转到文本框的属性并将CharacterCasing更改为Upper,现在所有输入都将是
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.


您必须将光标位置设置为文本的结尾,如下所示:
You have to set the cursor position to the end of the text like this:
void textBox1_TextChanged(object sender, EventArgs e)
{
    textBox1.Text = textBox1.Text.ToUpper();
    textBox1.Select(textBox1.Text.Length, 0);
}



欢呼声
安迪



cheers
Andy


这篇关于在text_change事件中将字符串从低位转换为高位的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆