2009-02-11 99 views

回答

3

解决方案:

private void dataGridView3_CellBeginEdit(object sender, DataGridViewCellCancelEventArgs e) { 
    if (e.RowIndex < 3) { 
     e.Cancel = true; 
    } 
} 

private void dataGridView3_UserDeletingRow(object sender, DataGridViewRowCancelEventArgs e) { 
    if (e.Row.Index < 3) { 
     e.Cancel = true; 
    } 
} 
1

一种方式做到这一点是捕捉_CellBeginEdit事件,检查是否对目标行中的任何修改都是允许的,并取消事件如果允许无编辑:

私人无效dataGridViewIndexesSpecs_CellBeginEdit(对象发件人,DataGridViewCellCancelEventArgs E) {

 if (e.RowIndex <= 3) 
      e.Cancel = true; 

    } 
+0

会阻止他们删除它吗? – Malfist 2009-02-11 22:04:28