private void btnAdd_Click(object sender, EventArgs e) { ControlsDisabled(); // It's enough to disable here contactForm = new FormContact(); if (contactForm.ShowDialog() == DialogResult.OK) { contact = contactForm.contact; // You need only the Contact object contacts.Add(contact); // You add the contact to to bound list txtFname.Text = contact.FirstName; txtLname.Text = contact.LastName; } ControlsEnabled(); // Enable even if dialog fails }
private void btnEdit_Click(object sender, EventArgs e) { ControlsDisabled(); contact = lstBoxAdd.SelectedItem as Contact; // Retrieve selected Contact contactForm = new ContactForm(contact); // Pass it to the contactForm if (contactForm.ShowDialog() == DialogResult.OK) { contact = contactForm.contact; txtFname.Text = contact.FirstName; txtLname.Text = contact.LastName; //lstBoxAdd.Items.Add(contact.firstname + " " + contact.lastName); --> Not needed } ControlsEnabled(); }