/// <summary> /// 删除 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void button_del_Click(object sender, EventArgs e) { int rowIndex = dataGridView1.CurrentRow.Index; DialogResult result; result = MessageBox.Show("确定要删除数据吗? \r\n确定:删除数据 \r\n取消:取消本次操作", "退出", MessageBoxButtons.OKCancel, MessageBoxIcon.Question); if (result == DialogResult.Cancel) { return; } try { DataTable dtupdate = (DataTable)dataGridView1.DataSource; Form_gzzBll SjzdBll = new Form_gzzBll(); if (dtupdate != null && dtupdate.Rows.Count > 0 && dtupdate.Rows.Count > rowIndex) { SjzdBll.Del(dtupdate, rowIndex); } dataSelect(); MessageBox.Show("删除成功!"); } catch (Exception ex) { MessageBox.Show("删除失败!" + ex.Message); } }