C# 获取DataGridView中的复选框
2011-12-03 21:33 Andrew.Wangxu 阅读(601) 评论(0) 编辑 收藏 举报如图:
根据选中的复选框获得ID。
代码如下:
List<string> ids = new List<string>();
foreach (DataGridViewRow row in dgrd_Human.Rows)
{
if (row.Cells["selected"].Value != null)
{
if(row.Cells["selected"].Value.ToString() == "True")
ids.Add(row.Cells[1].Value.ToString());
}
}
MessageBox.Show(string.Join(",", ids.ToArray()));