本文介绍了按键,按键,按键?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

您好,



i已经阅读了按键,按键,按键事件,但我无法通过任何代码示例测试它...可能你请帮我一个这个事件的简单代码......?





我尝试过但按Enter键时无法正常工作? :(



Hello ,

i have read the key press, key down , key up event but i couldn''t test it by any code example ... may u help me please for a simple code of this events ...?


i tried it but not working when i press Enter Key? :(

private void textBox1_Keydown(object sender, KeyPressEventArgs e)
       {
           if (e.KeyChar == (char)Keys.Enter)
           {
               string s = textBox1.Text;
               messagebox.show("Enter is down " + s);

           }
       }









非常感谢





many thanks

推荐答案

private void textBox1_Keydown(object sender, KeyEventArgs e)
{
    if (e.KeyCode == Keys.Up) // or Keys.Down, Keys.Left, Keys.Right
    {
         // do something...
    }
}



希望这会有所帮助。


Hope this helps.


这篇关于按键,按键,按键?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-13 15:21