예제 #1
0
 private void editButton_Click(object sender, EventArgs e)
 {
     if (peopleListBox.SelectedItem is Person person)
     {
         var editForm = new AddForm(person);
         var result   = editForm.ShowDialog();
         if (result == DialogResult.OK)
         {
             var index = peopleListBox.SelectedIndex;
             people.RemoveAt(index);
             people.Insert(index, editForm.Person);
             peopleListBox.Items.RemoveAt(index);
             peopleListBox.Items.Insert(index, editForm.Person);
         }
     }
 }