Chinthaka Bandara

Chinthaka Bandara

  • NA
  • 37
  • 12.5k

datagridview checkbox column value

May 20 2010 2:22 AM
I have this problem.i tried many ways.but i couldn't find a solutin for my problem

I have a datagridview with a checkbox column.i want to check whether checkbox is checked or not.

 private void btn_Generate_Click(object sender, EventArgs e)
{
for (int i = 0; i < dataGridView1.Rows.Count-1; i++)
{
string values = dataGridView1.Rows[i].Cells[4].Value.ToString();
MessageBox.Show(values);
}
}

if the checkbox is selected it will output as "True" in messagebox.but if checkbox is not selected it is giving me an error

"Object reference not set to an instance of an object."

i want to get output when checkbox is not checked also

please help me....
Thank you..................

Answers (4)