总是大写...(C#winforms) [英] Always in upper case... (C# winforms)

查看:121
本文介绍了总是大写...(C#winforms)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的表单中有一个TextBox,并在其上添加了此事件:

I have a TextBox in my form and I added this event on it:

private void txtValue_KeyDown(object sender, KeyEventArgs e)
        {
            MessageBox.Show(e.KeyData.ToString());
        }

但是,即使我在文本框中输入了小写字母,它也会始终打印字母的大写字母.请参见下图:

But it always prints the upper case of the letter even though I entered a lower case letter in the textBox. Please see image below:

我应该如何获得正确的显示?谢谢...

How should I get the right display? Thanks...

推荐答案

KeyDownKeyUp使用KeyEventArgs,这通过KeyData属性公开了Keys枚举.枚举不具有小写字母值的表示形式.

KeyDown and KeyUp use KeyEventArgs, which exposes the Keys enum via the KeyData property. The enum does not have representation for lower-case alphabetic values.

http://msdn.microsoft.com /en-us/library/system.windows.forms.keys.aspx

KeyPress事件允许您通过KeyPressEventArgs.KeyChar获取按键的实际字符.

The KeyPress event allows you to get the actual character of the key pressed via KeyPressEventArgs.KeyChar.

private void txtValue_KeyPress(object sender, KeyPressEventArgs e)
{
    MessageBox.Show(e.KeyChar.ToString());
} 

这篇关于总是大写...(C#winforms)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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