private void dataGridView2_CellContentClick(object sender, DataGridViewCellEventArgs e) { if (e.RowIndex != -1) { if (this.dataGridView2.CurrentCell.OwningColumn.Name == "删除")//q(Msg_Type.fielddelete) { int index = dataGridView2.CurrentRow.Index; BindList.RemoveAt(index); for (int i = 0; i < BindList.Count; i++) { BindList[i].XH = (i + 1); } int a = dataGridView2.Columns.Count; if (BindList.Count == 0) { dataGridView2.DataSource = new List <MES_TM_TMINFO_LIST>(); dataGridView2.Columns["删除"].DisplayIndex = 4;//q(Msg_Type.fielddelete) } else { dataGridView2.DataSource = BindList.ToArray(); dataGridView2.Columns["删除"].DisplayIndex = 4;//q(Msg_Type.fielddelete) } dataGridView2.ClearSelection(); Verify(); } } }