for (int RowCount = 1; RowCount <= strfile.Length - 1; RowCount++) { if (strfile[RowCount].ToString() != "") { if (RowCount != 0) { string[] column = strfile[RowCount].Split('þ'); for (int i = 1; i < column.Length - 1; i++) { if (cmbColumnCombo.SelectedIndex == ((i - 1) / 2)) { if (!string.IsNullOrEmpty(column[i]) && column[i].ToString() != "\u0014") { dataGridView1.Rows.Add(); DateTime Time = Convert.ToDateTime(column[i].ToString()); dataGridView1.Rows[RowCount - 1].Cells[txtColumnName.Text.Replace(" ", "")].Value = Time.ToString("HH:mm:ss"); dataGridView1.Rows[RowCount - 1].Cells[cmbColumnCombo.Text].Value = Time.ToString("dd/MM/yyyy"); //dataGridView1.Rows[RowCount - 1].Cells[cmbColumn1.Text].Value += column[i].ToString(); } } } for (int i = 1; i < column.Length - 1; i++) { if (cmbIdentity.SelectedIndex == ((i - 1) / 2)) { if (!string.IsNullOrEmpty(column[i]) && column[i].ToString() != "\u0014") { dataGridView1.Rows[RowCount - 1].Cells[cmbIdentity.Text].Value += column[i].ToString(); } } } } } }