dataGridView1怎么右键删除选中的行,可以是多行数据

.Net技术 码拜 8年前 (2016-03-03) 1380次浏览
伪代码

 private void toolStripMenuItem2_Click(object sender, EventArgs e)
        {
          dataGridViewFuture
            dataGridView1.DataSource = db.ExecuteDataView(sqlDataFuture);
        }
解决方案

100

上面有问题,这样才对

if (this.dataGridView1.SelectedRows.Count > 0)   
{                               
 //遍历所选中的dataGridView记录行                       
foreach (DataGridViewRow row in this.dataGridView1.SelectedRows)                      
 {                                        
//取dataGridView1中的第一列的值                           
string id= row.Cells[0].Value.ToString();                           
string sql = "delete  tb   where id="+id+"";                         
 db.ExecuteNonQuery(sql); 
 } 
} 

CodeBye 版权所有丨如未注明 , 均为原创丨本网站采用BY-NC-SA协议进行授权 , 转载请注明dataGridView1怎么右键删除选中的行,可以是多行数据
喜欢 (0)
[1034331897@qq.com]
分享 (0)