I have a windows form which is a countdown Timer. What is the best way for me to pause the timer by pressing the spacebar on the keyboard. I have three buttons on the form for start, pause and stop and res-set. However I also want to pause, restart on press off spacebar. I tried to add a fourth button and then made 开发者_如何学Goit hidden on the form and added the following code (changed the EventArgs to KeyEventArgs:
    private void button1_Click(object sender, KeyEventArgs e)
    {
       if (e.KeyCode == Keys.Space)
           // Pause the timer.  
       timer1.Enabled = false;
       paused = true;
       Start.Enabled = true;
       Pause.Enabled = false;  
    }
However when i try to run this i get the error - No overload for 'button1_Click matches delegate System.EventHandler
Is there something I have missed or a better way off doing this.
Any Help/Advice would be appreciated.
The Click event doesn't take a KeyEventArgs.
You're looking for the form's KeyPress event.
 
         
                                         
                                         
                                         
                                        ![Interactive visualization of a graph in python [closed]](https://www.devze.com/res/2023/04-10/09/92d32fe8c0d22fb96bd6f6e8b7d1f457.gif) 
                                         
                                         
                                         
                                         加载中,请稍侯......
 加载中,请稍侯......
      
精彩评论