private void toolStrip_delete_Click(object sender, EventArgs e) { //选中某一个学生信息,删除学生信息 if (dataGridView1.SelectedRows.Count == 1) { if (MessageBox.Show("确定删除此学生信息?", "确认信息", MessageBoxButtons.YesNo, MessageBoxIcon.Warning, MessageBoxDefaultButton.Button2) == DialogResult.Yes) { int selectrow = Int32.Parse(dataGridView1.Rows[dataGridView1.CurrentCell.RowIndex].Cells[0].Value.ToString()); if (StudentInfoBLL.DeleteStudentInfo(selectrow)) { MessageBox.Show("删除学生信息成功!"); } else { MessageBox.Show("删除学生信息失败,请确认是否选中学生信息"); } initContracts(); } } else { MessageBox.Show("请选中一行后再点击删除!"); } }