In the same issue, I tried several methods, but could not succeed. As one answer says:
for(int i = 0; i < myDataGridView.Rows.Count; i++) { myDataGridView.Rows.RemoveAt(i) }
will actually delete the line, but the next line will be moved to the previous line! So the above approach removes half the number of rows! Therefore, you need to repeat the action until it becomes zero!
Alternatively, try removing from the last line to the first. He works!
for(int i = myDataGridView.Rows.Count - 1; i >= 0; i--) { myDataGridView.Rows.RemoveAt(i); }
source share