private void button2_Click(object sender, EventArgs e) { List <string> newValue = new List <string>(); newValue.Add(comboBox2.Text); string[] info = textBox4.Text.Split('\n'); for (int i = 0; i < info.Length; i++) { newValue.Add(info[i].Split('\r')[0]); } selectedPerson.ChangeValue(newValue); persons[dataGridView1.SelectedRows[0].Index] = selectedPerson.Copy(); dataGridView1.Rows.Clear(); for (int i = 0; i < persons.Count; i++) { dataGridView1.Rows.Add(); List <string> personData = persons[i].ReturnData(); dataGridView1[0, i].Value = personData[0]; dataGridView1[1, i].Value = personData[1]; dataGridView1[2, i].Value = personData[2]; for (int j = 3; j < personData.Count; j++) { dataGridView1[3, i].Value += personData[j] + " "; } } }
private void button3_Click(object sender, EventArgs e) { List <string> newValue = new List <string>(); newValue.Add(comboBox2.Text); string[] info = textBox4.Text.Split('\n'); for (int i = 0; i < info.Length; i++) { newValue.Add(info[i].Split('\r')[0]); } newPerson.ChangeValue(newValue); dataGridView1.Rows.Add(); newPerson.SetId(dataGridView1.Rows.Count); List <string> personData = newPerson.ReturnData(); dataGridView1[0, dataGridView1.Rows.Count - 1].Value = personData[0]; dataGridView1[1, dataGridView1.Rows.Count - 1].Value = personData[1]; dataGridView1[2, dataGridView1.Rows.Count - 1].Value = personData[2]; for (int j = 3; j < personData.Count; j++) { dataGridView1[3, dataGridView1.Rows.Count - 1].Value += personData[j] + " "; } persons.Add(newPerson); }