2010-12-03 56 views

回答

1

我不是认为你强制它是全部大写,但是正在做一个.ToUpper()的值他们键入一个可能的解决方案?

0

您必须使用TextChanged事件。

private void textBox_TextChanged(object sender, TextChangedEventArgs e) 
{ 
    // Save cursor's position 
    int cursorLocation = textBox1.SelectionStart; 

    // Uppercase text 
    textBox.Text = textBox1.Text.ToUpper(); 

    // Restore cursor's position 
    textBox.SelectionStart = cursorLocation; 
} 

source

+1

谢谢卢卡斯,那作品!我所追求的是获得与原生应用程序相同的行为,将焦点移至文本框,键盘随CAPS ON一起弹出,输入第一个字母后返回CAPS OFF。我应该更好地解释。我发现使用InputScope和InputScopeNames玩这个技巧。我特别想找的名字是InputScopeNameValue.PersonalFullName。 – 2010-12-03 17:22:47

1

这样就更好了:

private void codeTextChanged(object sender, TextChangedEventArgs e) 
{ 
    tPCodeText.Text = (sender as TextBox).Text.ToString().ToUpper(); 
    tPCodeText.SelectionStart++; 
} 
相关问题