Skipping KeyDown On Override ProcessCmdKey EventHandller

前端 未结 1 1337
自闭症患者
自闭症患者 2021-01-26 02:50

I have a simple increment on textbox by pressing down arrow key which are as below.

protected override bool ProcessCmdKey(ref Message msg, Keys keyData)
{

              


        
相关标签:
1条回答
  • 2021-01-26 03:41

    You'll need to handle other commands that existed before and return when you handle ones you are looking for. Try changing it to this and see if that helps:

    protected override bool ProcessCmdKey(ref Message msg, Keys keyData)
    {
       if (msg.WParam.ToInt32() == (int)Keys.Down)
       {
          int c = int.Parse(textBox1.Text);
          c++;
          textBox1.Text = c.ToString();
          return true;
       }
       return base.ProcessCmdKey(ref msg, keyData);
    }
    
    0 讨论(0)
提交回复
热议问题