Error is in this part of code:
for (int i = 1; i <= DGV_CsvFile.Rows.Count; i++) {
part1 = DGV_CsvFile.Rows[i].Cells[0].Value.ToString();
part2 = DGV_CsvFile.Rows[i].Cells[1].Value.ToString();
result =result + part1+" : "+part2+"\n";
}
Well, indexing in the Datagrid rows start from zero (0) and not one.
If you have 5 rows, you are trying to access 1 to 5 instead it should be 0 to 4.
Make the following change:
for (int i = 0; i < DGV_CsvFile.Rows.Count; i++)
i started from zero and the limiting condition is till rowCount.