Datagridview Checkbox column Problem
Hi i want to get selected Checkbox value inside a datagridview. how can i check the status of the check box.. i used following code for this. but its not working.
private void dataGridView1_CellContentClick(object sender, DataGridViewCellEventArgs e)
{
StringBuilder sb = new StringBuilder();
for (int i = 0; i < dataGridView1.Rows.Count; i++)
{
if ((bool)this.dataGridView1.Rows[i].Cells[i].Value == true)
{
sb.Append(dataGridView1.Rows[i].Cells[i].ToString());
}
}
}
1 Answer
Know the answer? Post it. Somebody with the same question will find it here.

Roei BarRank #1,271 · 1.4K reputationPosted Sep 2, 2009, 11:34 PM EDT
private List selectedCheckBox = new List() private void dataGridView1_CellContentClick(object sender, DataGridViewCellEventArgs e) { for (int i = 0; i < dataGridView1.Rows.Count; i++) { if ((bool)this.dataGridView1.Rows[i].Cells["Selected"].Value == true) { selectedCheckBox.Add(i); } } }