[英]Visual Studio c# Key press enter not working
大家好,我一直在努力编写代码! 我做了一些研究,但我不明白为什么我的代码无法正常工作...请帮助!
private void CheckEnter(object sender, System.Windows.Forms.KeyPressEventArgs e)
{
if (e.KeyChar == (char)13)
{
Debug.WriteLine("It's working!");
enterKey = true;
}
else
{
enterKey = false;
}
}
private void textBox_TextChanged(object sender, TextChangedEventArgs e)
{
Debug.WriteLine("The text is changing");
if (enterKey == true)
{
encryptKey = encryptInTextBox.Text;
Debug.WriteLine("The key is " + encryptKey);
}
}
显然,由于文本框的创建方式,我无法更改“ TextChangedEvenArgs”,每当更改它时,都会出现错误。 因此,我决定采用这种方式,谢谢您的帮助!
为什么不直接在文本框KEYPRESS或KEYUP事件中检查ENTER键?
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.