日期:2014-05-17  浏览次数:20840 次

怎么点了按钮之后没有反应
这是代码,实现删除datagridview里被勾选的项。点完之后没有任何反应,也不报错。
private void button6_Click(object sender, EventArgs e)
        {
            int selectedRows = dataGridView2.SelectedRows.Count;
            for (int j = 0; j < selectedRows; j++)
            {
                try
                {
                    if (dataGridView2.Rows[j].Cells["选择"].Value != null)
                    {
                        if (bool.Parse(dataGridView2.Rows[j].Cells["选择"].Value.ToString()) == true)
                        {
                            MessageBox.Show("123");
                            string DElsql = string.Format("Delete From Question Where QuestionID = {0}", Convert.ToInt32(dataGridView2.SelectedRows[0].Cells["题号"].Value));
                            conn.Open();
                            SqlCommand cmd = new SqlCommand(DElsql, conn);
                            cmd.ExecuteNonQuery();
                            conn.Close();
                            dataview();

                        }
                    }
                }
                catch (Exception ex)
                { MessageBox.Show(ex.Message); }
               
            }