vb.net 怎样循环遍历datagridview里的checkbox列

Emt__Only 2010-05-31 01:42:00
请指教啦
...全文
604 5 打赏 收藏 转发到动态 举报
写回复
用AI写文章
5 条回复
切换为时间正序
请发表友善的回复…
发表回复
Tosp2012 2011-06-03
  • 打赏
  • 举报
回复

For Each row As DataGridViewRow In dataGridView1.Rows
If row.Cells(x).Value = True Then
...
End If
Next
  • 打赏
  • 举报
回复
int checkedCount = 0;
int j=-1;
string teacherName=null;
foreach (DataGridViewRow dr in this.dgv_TeacherInfo.Rows)
{
j = j + 1;
DataGridViewCheckBoxCell cbx = (DataGridViewCheckBoxCell)dr.Cells["Delete"];
if ((bool)cbx.FormattedValue==true)
{
checkedCount = checkedCount + 1;
//选中,得到改行的教师name
teacherName=this.dgv_TeacherInfo.Rows[j].Cells["TName"].Value.ToString();
//调用方法根据name删除该数据
//...............
}
}
MessageBox.Show(checkedCount.ToString());
if (checkedCount==0)
{
MessageBox.Show("请选择要删除项!");
return;
}
wuyq11 2010-06-01
  • 打赏
  • 举报
回复
For Each dr As DataGridViewRow In Me.dataGridView1.Rows
Dim cbx As DataGridViewCheckBoxCell = DirectCast(dr.Cells(0), DataGridViewCheckBoxCell)
If Not CBool(cbx.FormattedValue) Then

End If
Next
wuyq11 2010-06-01
  • 打赏
  • 举报
回复
foreach (DataGridViewRow dr in this.dataGridView1.Rows)
{
DataGridViewCheckBoxCell cbx = (DataGridViewCheckBoxCell)dr.Cells[0];
if (!(bool)cbx.FormattedValue)
{

}
}
骚军 2010-06-01
  • 打赏
  • 举报
回复
期待,学习

16,554

社区成员

发帖
与我相关
我的任务
社区描述
VB技术相关讨论,主要为经典vb,即VB6.0
社区管理员
  • VB.NET
  • 水哥阿乐
  • 无·法
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

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