winform中使用複合鍵判斷

  • 2626
  • 0
  • C#
  • 2010-11-04

摘要:winform中使用複合鍵判斷

 在寫winform時

發現可以判斷使用者是否按下複合鍵而做後續的動作

例如按ctrl+delete的話

就可以用如下的判斷,我是寫在PreviewKeyDown事件中


 private void dg_PreviewKeyDown(object sender, PreviewKeyDownEventArgs e)
 {
      
 if (e.Control && e.KeyCode == Keys.Delete && this.dg.CurrentRow != null) 
         this.DeleteRow(this.dg.CurrentRow.Index);
 }

 

 

記起來,以後用的到