private void btnCategoryDelete_Click(object sender, EventArgs e) { try { DialogResult d = MessageBox.Show("Are you sure you want to delete?", "Delete", MessageBoxButtons.YesNo); if (d == DialogResult.Yes) { StatusRepo.delete(this.id); MessageBox.Show("Status has been deleted."); List <SMLIB.Entity.Status> statuses = StatusRepo.retrieve(); fillListView(statuses); btnCategoryDelete.Enabled = false; btnCategoryUpdate.Enabled = false; btnCategoryAdd.Enabled = true; clearAll(); } } catch (Exception) { MessageBox.Show("Please select an item to delete."); } }