如何以编程方式将 Windows Phone 7 键盘设置为大写?

发布于 2024-10-05 16:17:03 字数 58 浏览 0 评论 0原文

我可以手动完成,但是如何从代码中设置它,以便当我将焦点放在文本框上时,键盘将允许用户开始输入大写字母?

I can do it manually, but how can I set this from my code, so when I give focus to a textbox the keyboard will allow the user to start typing in UPPER CASE?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

囚我心虐我身 2024-10-12 16:17:03

我不认为您强制它全部大写,但是对他们在可能的解决方案中键入的值执行 .ToUpper() 吗?

I don't think you force it to be all upper case, but is doing a .ToUpper() on the value they type in a possible solution?

苯莒 2024-10-12 16:17:03

这种方式更好:

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

This way is even better:

private void codeTextChanged(object sender, TextChangedEventArgs e)
{
    tPCodeText.Text = (sender as TextBox).Text.ToString().ToUpper();
    tPCodeText.SelectionStart++;
}
音栖息无 2024-10-12 16:17:03

您必须使用 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;
} 

来源

You have to use TextChanged event.

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

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文