总是大写……(C#winforms)

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

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

但它始终打印字母的大写字母,即使我在textBox中输入了一个小写字母。 请看下面的图片:

我的表格

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

KeyDownKeyUp使用KeyEventArgs ,它通过KeyData属性公开Keys枚举。 枚举没有小写字母值的表示。

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

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

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

如果您处理KeyPress事件,则可以检查KeyPressEventArgsKeyChar属性以获取正确的大小写。