The only indexing you are using is to access the rows and cells - at a guess you don't have sufficient cells in your DataGridView, so use the dubugger to check exactly what is happening while your code is running.
But ... never use DoEvents: it's a poor way to bodge round a problem. And in this case, it's bodging round a problem you don't have, because the code using DoEvents is on a separate thread already and that thread doesn't have a message pump so DoEvents will do nothing useful (if it isn't actually causing your app to crash already).
Plus ... that code looks like it wasn't thought about too much:
int percents = (i * 100) / total;
Given that total is an integer and you set it to 100 but never change it, that code is equivelant to writing
int percents = i;
but with more wasted processor time ...