private void CourseRemove_Click(object sender, EventArgs e)//删除按钮功能 { var rows = CourseList.SelectedRows; if (rows.Count > 0) { DialogResult result = MessageBox.Show("确定要删除吗?", "提示", MessageBoxButtons.OKCancel); if (result == DialogResult.Cancel) { return; } string cno = rows[0].Cells[0].Value.ToString(); CourseBLL courseBLL = new CourseBLL(); if (courseBLL.Remove(cno)) { MessageBox.Show("删除成功"); LoadCourseList(); } else { MessageBox.Show("删除失败"); } } else { MessageBox.Show("请选择要删除的行"); } }