获得DataGridView多选框值

在DataGridView中添加一个CheckBox例

 

DataGridView控件名称:dSearchResult

string strCode = string.Empty;
                for (int i = 0; i < dSearchResult.Rows.Count; i++)
                {
                    if (dSearchResult.Rows[i].Cells[0].Value != null) //判断该行的复选框是否存在
                    {
                        if (dSearchResult.Rows[i].Cells[0].Value.ToString() == "True") //判断该复选框是否被选中
                        {
                            strCode += dSearchResult.Rows[i].Cells[2].Value.ToString() + "|";
                        }
                    }
                }

 

 

posted @ 2012-04-11 11:10  LiTao9026  阅读(964)  评论(0编辑  收藏  举报