private void btAdd_Click(object sender, EventArgs e) { FormForAdd form = new FormForAdd(user, index); form.ShowDialog(); if (form.DialogResult == DialogResult.OK) { user.contacts = new List<Contact>(); foreach (Contact ct in form.list.contacts) { user.contacts.Add(ct); } } form.list.contacts.Sort(); dgUsers = createDataGridView(); for (int i = 0; i < form.list.contacts.Count; i++) { dgUsers.Rows.Add(); dgUsers.Rows[i].Cells[0].Value = form.list.contacts[i].surname + " " + form.list.contacts[i].name + " " + form.list.contacts[i].patronymic; StringBuilder sb = new StringBuilder(); foreach (PhoneNumber number in user.contacts[i].numbers) { sb.Append(number.ToString() + " "); } dgUsers.Rows[i].Cells[1].Value = sb; } }
private void btAdd_Click(object sender, EventArgs e) { FormForAdd form = new FormForAdd(user, index); form.ShowDialog(); if (form.DialogResult == DialogResult.OK) { user.contacts = new List <Contact>(); foreach (Contact ct in form.list.contacts) { user.contacts.Add(ct); } } form.list.contacts.Sort(); dgUsers = createDataGridView(); for (int i = 0; i < form.list.contacts.Count; i++) { dgUsers.Rows.Add(); dgUsers.Rows[i].Cells[0].Value = form.list.contacts[i].surname + " " + form.list.contacts[i].name + " " + form.list.contacts[i].patronymic; StringBuilder sb = new StringBuilder(); foreach (PhoneNumber number in user.contacts[i].numbers) { sb.Append(number.ToString() + " "); } dgUsers.Rows[i].Cells[1].Value = sb; } }