private void btnStep3_Click(object sender, EventArgs e) { tabControl1.SelectedTab = tabPage3; // Trouver les colonnes nom/prénom int iNom = -1, iPrenom = -1; int idx = 0; foreach (DataGridViewRow row in dgvSelection.Rows) { if (row.Cells[colDestination.Index].Value.ToString() == m_colDest[1]) { iNom = idx; } if (row.Cells[colDestination.Index].Value.ToString() == m_colDest[2]) { iPrenom = idx; } idx++; } if (iNom != -1 && iPrenom != -1) { dgvSelection.Rows.Clear(); using (System.IO.StringReader sr = new System.IO.StringReader(txtInput.Text)) { string line = null; while ((line = sr.ReadLine()) != null) { var separator = Parsing.GetHeaderSeparator(line); var items = Parsing.SmartSplit(line, separator); if (iNom < items.Count && iPrenom < items.Count) { dgvCheck.Rows.Add(new object[] { items[iNom], items[iPrenom] }); } } } } else { MessageBox.Show("Veuillez sélectionner nom et prénom pour pouvoir continuer."); tabControl1.SelectedTab = tabPage2; } }
private void btnStep2_Click(object sender, EventArgs e) { tabControl1.SelectedTab = tabPage2; // Détecter le séparateur de colonne using (System.IO.StringReader sr = new System.IO.StringReader(txtInput.Text)) { string line = sr.ReadLine(); if (line != null) { var separator = Parsing.GetHeaderSeparator(line); var items = Parsing.SmartSplit(line, separator); for (int i = 0; i < items.Count; i++) { dgvSelection.Rows.Add(new object[] { $"Colonne {i + 1}", m_colDest[0], items[i] }); } } else { MessageBox.Show("Fichier vide."); } } }