怎样在winform中给GridView设全选功能?

totodele 2010-07-18 05:18:23
如题
...全文
197 4 打赏 收藏 转发到动态 举报
写回复
用AI写文章
4 条回复
切换为时间正序
请发表友善的回复…
发表回复
wuyq11 2010-07-18
  • 打赏
  • 举报
回复
for (int i = 0; i <= dataGridView1.Rows.Count - 2; i++) {
if (dataGridView1.Rows[i].Cells["a"].Value.ToString().Equals("1")) {
dataGridView1.Rows[i].Cells["CheckBox"].Value = true;
}
else {
dataGridView1.Rows[i].Cells["CheckBox"].Value = false;
}
}
foreach (DataGridViewRow dr in this.dataGridView1.Rows)
{
try
{
DataGridViewCheckBoxCell cbx = (DataGridViewCheckBoxCell)dr.Cells[0];
if ((bool)cbx.FormattedValue)
{
str+= dr.Cells[1].Value;
}
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
}
}

totodele 2010-07-18
  • 打赏
  • 举报
回复
沉了
自己顶起!
totodele 2010-07-18
  • 打赏
  • 举报
回复
沉了
自己顶起!
totodele 2010-07-18
  • 打赏
  • 举报
回复
沉了
自己顶起!

17,740

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术 .NET Framework
社区管理员
  • .NET Framework社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧