本文介绍了删除后,datagridview应该刷新,但它不能在Windows窗体中工作的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述 private void Delete_Click(对象发件人,EventArgs e) { for ( int i = 0 ; i < dataGridView2.SelectedRows.Count; i ++) { string sql = 从[删除] SAPProduction]。[ProductionData] + 其中id =' + dataGridView2.CurrentRow .Cells [ id]。Value.ToString()+ '; // Jobcard =您的愿望行名片ID SqlCommand cmd = new SqlCommand(sql,objConn1); objConn1.Open(); cmd.ExecuteNonQuery(); objConn1.Close(); MessageBox.Show( 记录已成功删除...); dataGridView2.Refresh(); } } 解决方案 private void Delete_Click(object sender, EventArgs e) { for (int i = 0; i < dataGridView2.SelectedRows.Count; i++) { string sql = "Delete from [SAPProduction].[ProductionData] " + " Where id = '" + dataGridView2.CurrentRow.Cells["id"].Value.ToString() + "' "; // Jobcard = your desire Rows Jobcard Id SqlCommand cmd = new SqlCommand(sql, objConn1); objConn1.Open(); cmd.ExecuteNonQuery(); objConn1.Close(); MessageBox.Show("Record Deleted successfully..."); dataGridView2.Refresh(); } } 解决方案 这篇关于删除后,datagridview应该刷新,但它不能在Windows窗体中工作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持! 09-21 05:00