參考:
Escaping DataGridView Row creation fires RowValidating. How to avoid this?
1)
private void dataGridView1_KeyDown(object sender, KeyEventArgs e) 
{ 
     if (e.KeyCode == Keys.Escape) 
     { 
          this.dataGridView1.RowValidating -= 
               new System.Windows.Forms.DataGridViewCellCancelEventHandler(this.dataGridView1_RowValidating); 
     } 
     this.dataGridView1.RowValidating += 
          new System.Windows.Forms.DataGridViewCellCancelEventHandler(this.dataGridView1_RowValidating); 
}
2)
if (!view.IsCurrentRowDirty ) return; 
 
沒有留言:
張貼留言