public void SaveChanges(Sportsmen chs) // Функция сохранения изменений { Sportsmen changesave = new Sportsmen(); sportsmens.RemoveAt(index); sportsmens.Insert(index, chs); changesave.Save(); }
public static int index = 0;//индексатор private void button3_Click(object sender, EventArgs e) { string type = comboBox1.SelectedItem.ToString(); Sportsmen NewSportsmen = new Sportsmen(textBox4.Text, Int32.Parse(numericUpDown2.Value.ToString()), textBox3.Text, textBox2.Text, maskedTextBox1.Text, textBox1.Text, Int32.Parse(numericUpDown1.Value.ToString()), Int32.Parse(numericUpDown4.Value.ToString()), Int32.Parse(numericUpDown3.Value.ToString()), type); sportsmens.Add(NewSportsmen); NewSportsmen.Save(); }
private void button1_Click(object sender, EventArgs e) { if (dataGridView1.SelectedRows != null) { Sportsmen del = new Sportsmen(); int count = dataGridView1.CurrentRow.Index; string s = dataGridView1[0, count].Value.ToString(); index = 0; foreach (Sportsmen sport in sportsmens) { index++; if (sport.Name == s) { break; } } sportsmens.RemoveAt(index); del.Save(); } }