for (int i = 2; i <= SCdataGridView1.Rows.Count;i++)
{
int malecount = 0;
if (SCdataGridView1.Rows[i].Cells[8].Value.ToString() == "Male") //here the error occure because I put here i
{
malecount = malecount + 1;
SClabel6.Text = malecount.ToString();
}
}
error is
Index was out of range. Must be non-negative and less than the size of the collection.
Parameter name: index
Loading

Kirtan PatelPosted Oct 24, 2009, 8:55 AM
what happened to you why you unchecked my answer" ?? :( does it not helped you ????
jingePosted Oct 24, 2009, 7:54 AM
Kirtan PatelPosted Oct 24, 2009, 7:53 AM
for (int i = 2; i <= SCdataGridView1.Rows.Count-1;i++)
{
int malecount = 0;
if (SCdataGridView1.Rows[i].Cells[8].Value.ToString() == "Male")
{
malecount = malecount + 1;
SClabel6.Text = malecount.ToString();
}
}
or you can also write i