如图:

C# 获取DataGridView中的复选框

 

根据选中的复选框获得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()));


参考:http://www.wxzzz.com/?id=48

相关文章: