未绑定数据的情况:
var dgv = new System.Windows.Forms.DataGridView();
var checkedItems = dgv.Rows.Cast
.Where(item => true.Equals(item.Cells[0].Value));
可惜了,好东西看不懂也是没用的。。。
private void dataGridView1_CellContentClick(object sender, DataGridViewCellEventArgs e)
{
int count = dataGridView1.Rows.Count;
for (int i = 0; i < count; i++)
{
DataGridViewCheckBoxCell checkCell = (DataGridViewCheckBoxCell)dataGridView1.Rows[i].Cells[0];
Boolean flag = Convert.ToBoolean(checkCell.Value);
if (flag == true) //查找被选择的数据行
{
checkCell.Value = false;
}
else
continue;
}
}
}