private void DeleteContact() { var item = GetSelectedContact(); if (item == null) { return; } if (MessageBox.Show($"Are you sure you want to delele " + _listContacts.DisplayMember + "?", "Delete Confirmation", MessageBoxButtons.YesNo) == DialogResult.No) { return; } _contactDatabase.Remove(item.Name); RefreshContacts(); }
private void DeleteContact() { ContactItem contactItem = GetSelectedContact(); if (contactItem == null) { return; } if (MessageBox.Show(this, $"Delete {contactItem.ContactName}", $"Are you sure you want to Delete {contactItem.ContactName} from your Contacts", MessageBoxButtons.YesNo) == DialogResult.No) { return; } _contactDB.Remove(contactItem); RefreshList(); }
private void OnContactDelete(object sender, EventArgs e) { var selected = GetSelectedContact(); if (selected == null) { return; } //ask if user is sure they want to delete if (MessageBox.Show(this, $"Are you sure you want to delete \"{selected.Name}\"?", "Delete Contact", MessageBoxButtons.YesNo, MessageBoxIcon.Question) != DialogResult.Yes) { return; } _contacts.Remove(selected.Id); BindList(); }