【问题标题】:e.KeyCode returns 'A' instead of 'a' [duplicate]e.KeyCode 返回 'A' 而不是 'a' [重复]
【发布时间】:2018-06-11 14:03:18
【问题描述】:

listBox_KeyDown 中,我评估e.KeyCode 条件。但它会检测大写字符而不是小写字母(实际上是输入的)。我如何让它捕捉输入的实际字符?代码如下:

bool isLetterOrDigit = char.IsLetterOrDigit((char)e.KeyCode);
if (isLetterOrDigit == true)
{
    //Add the char to textBox
    txtINAME.Text += (char)e.KeyCode;
}

【问题讨论】:

  • 或者,如果这是关于 WPF(很难说)see this

标签: c# visual-studio-2015 textbox listbox keydown


【解决方案1】:

使用KeyPress 事件,它在KeyPressEventArgs 中有一个KeyChar 属性。它会让你知道被按下的实际角色

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2016-03-23
    • 1970-01-01
    • 1970-01-01
    • 2017-06-04
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多