我可以手动完成,但是如何从我的代码中设置它,所以当我将焦点放在文本框上时,键盘会让用户开始输入大写字母?
答案 0 :(得分:1)
我不认为你强迫它是全部大写,但是对他们在可能的解决方案中输入的值做了.ToUpper()吗?
答案 1 :(得分:1)
这种方式更好:
private void codeTextChanged(object sender, TextChangedEventArgs e)
{
tPCodeText.Text = (sender as TextBox).Text.ToString().ToUpper();
tPCodeText.SelectionStart++;
}
答案 2 :(得分: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;
}