//кнопка "изменить" private void button2_Click(object sender, EventArgs e) { try { if (dataGridView1.SelectedCells[0].ColumnIndex != -1) LastClick = dataGridView1.SelectedCells[0].RowIndex; else if (dataGridView1.SelectedRows[0].Index != -1) LastClick = dataGridView1.SelectedRows[0].Index; Add add = new Add(LastClick); add.ShowDialog(); sp.setlist(list); dataGridView1.Rows.Clear(); if (sp.getlist() != null) foreach (Person p in list) { dataGridView1.Rows.Add(p.name, p.pol, p.date, p.prof); } } catch { } radioButton1.Checked = false; radioButton2.Checked = false; radioButton3.Checked = false; radioButton4.Checked = false; radioButton5.Checked = false; radioButton6.Checked = false; }
//кнопка "добавить" private void button1_Click(object sender, EventArgs e) { Add add = new Add(-1); add.ShowDialog(); list = sp.getlist(); dataGridView1.Rows.Clear(); if (sp.getlist() != null) foreach (Person p in list) { dataGridView1.Rows.Add(p.name,p.pol,p.date,p.prof); } dataGridView1.RowCount = 15; radioButton1.Checked = false; radioButton2.Checked = false; radioButton3.Checked = false; radioButton4.Checked = false; radioButton5.Checked = false; radioButton6.Checked = false; }