如何获取DataGridView中通过checkbox选中的多行的值
2015-07-20
展开全部
//DG_List为datagridview控件
for (int i = 0; i < DG_List.RowCount; i++){if (DG_List.Rows[i].Cells [0].EditedFormattedValue.ToString() == "True")
//这里判断复选框是否选中{count++;}}if (count == 0){MessageBox.Show("请至少选择一条数据!", "提示");return;}else{if (MessageBox.Show(this, "您要更新数据么?", "提示", MessageBoxButtons.YesNo, MessageBoxIcon.Information).ToString() == "Yes"){for (int i = 0; i < count; i++){ps.Pexcute(" update cf_prj_certi set FIsPrint='"+number+"' where fid='" + DG_List.Rows[i].Cells["fnn"].Value.ToString() + "'"); //执行SQL}} else{return;}}} catch (Exception ex){MessageBox.Show(ex.ToString());
} this.ShowInfo(); //重新绑定datagridview}
for (int i = 0; i < DG_List.RowCount; i++){if (DG_List.Rows[i].Cells [0].EditedFormattedValue.ToString() == "True")
//这里判断复选框是否选中{count++;}}if (count == 0){MessageBox.Show("请至少选择一条数据!", "提示");return;}else{if (MessageBox.Show(this, "您要更新数据么?", "提示", MessageBoxButtons.YesNo, MessageBoxIcon.Information).ToString() == "Yes"){for (int i = 0; i < count; i++){ps.Pexcute(" update cf_prj_certi set FIsPrint='"+number+"' where fid='" + DG_List.Rows[i].Cells["fnn"].Value.ToString() + "'"); //执行SQL}} else{return;}}} catch (Exception ex){MessageBox.Show(ex.ToString());
} this.ShowInfo(); //重新绑定datagridview}
本回答被提问者和网友采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询