So, first, when people see you responding to a perfectly valid answer with stuff like, "useless, absolutely useless..." it definitely doesn't make anyone want to help you.
Secondly, yes, buy a book. Start with the basics of coding, because it's clear you haven't done that. From the question, I can only assume that you've done something like:
int i = 0;
while (true)
{
if (dataGridView1.Rows(i)...)
{
}
i++;
}
which would not be the correct way to do it at all.
Pretty much anything that controls a list will have a
Count
property. This tells you...wait for it...the number of items in that list. So, how about:
int i = 0;
while(i < dataGridView1.Rows.Count)
{
i++;
}
of course, that is the solution that you start with in a basic coding class. There are many, many other ways to do it and if you don't know them, then buy a book or find a class.