Multipal Selection checkboxes in DataGridView
hi,
i have one datagridview . which is bind from my database (Mysql). i want checkboxes in dgv for multipal select. i got chk boxes in dgv but i dont know why its showing me Error.
here is code for it.
private void dataGridView1_CellContentClick(object sender, DataGridViewCellEventArgs e)
{
for (int i = 0; i < dataGridView1.Rows.Count;i++)
{
error line//
if
{
((bool)this.dataGridView1.Rows[i].Cells["Select"].Value == true)
{
selectedCheckBox.Add(i);
}
}
}
// this is Error
Object reference not set to an instance of an object.
plz help me .
thanks in Advance


Roei BarRank #1,271 · 1.4K reputationPosted Sep 11, 2009, 3:54 AM EDT
foreach (DataGridViewRow dataGridRow in dataGridView1.Rows) { if (dataGridRow.Cells["checkbox_col"].Value != null && (bool)dataGridRow.Cells["checkbox_col"].Value) { // item is checked } else if (dataGridRow.Cells["checkbox_col"].Value == null) { // item is null } }Naeem KhanRank #2,072 · 698 reputationPosted Sep 11, 2009, 11:28 PM EDT
Roei BarRank #1,271 · 1.4K reputationPosted Sep 12, 2009, 4:07 AM EDT
Naeem KhanRank #2,072 · 698 reputationPosted Sep 14, 2009, 2:47 AM EDT