I have a datagrid which returns 4 columns and 244 rows. The 4th column has 3 different statuses "Completed", "In-Progress", "NotSarted" all though out the cells. I need to loop through each cell in the 4th column and read the value add them up and store them in a varibale.So i need to have 3 variables fort he 3 statuses. How do I do ths?
Here is the code that I have. I am not sure if this is the right way to do it or if there is
an easier way, the problem with this is after I run it it keeps telling me "Object reference not set to an instance of an object."
listNames = new List<string>();
foreach (DataGridViewRow row in dataGridView1.Rows)
{
foreach (DataGridViewCell cell in row.Cells)
{
int i = 0;
if (cell.Value.ToString() == "Completed")
{
i ++;
i += i;
}
MessageBox.Show(i.ToString());
}
}
}