如何键入密钥? [英] How to typecast Key?
本文介绍了如何键入密钥?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
如何键入此KeyPress?
Hi,
How to typecast this KeyPress?
if (e.eyChar = Keys.S)
{
timer1.Stop();
}
错误:
Error:
Error 1 Cannot implicitly convert type 'System.Windows.Forms.Keys' to 'char'. An explicit conversion exists (are you missing a cast?)
推荐答案
这应该可以解决问题.不要忘记''==''而不是您的''='';)
This should do the trick. Don''t forget the ''=='' instead of your ''='' ;)
if (e.KeyChar == (char)Keys.S)
{
}
if (e.KeyChar == (char) Keys.S)
{
MessageBox.Show(e.KeyChar.ToString());
}
这篇关于如何键入密钥?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文