C# 获取DataGridView中的复选框

来源:互联网 发布:网络心理误区 编辑:程序博客网 时间:2024/06/05 09:02

如图:



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


原创粉丝点击