把该窗体的KeyPreview属性设成true

 

 private void frmMain_KeyDown(object sender, KeyEventArgs e)
        {
           
            if (e.KeyCode == Keys.F1)
            {

            }
        }