private void btnCategoryDelete_Click(object sender, EventArgs e) { DialogResult d = MessageBox.Show("Are you sure you want to delete?", "Delete", MessageBoxButtons.YesNo); if (d == DialogResult.Yes) { int index = 0; try { index = lvSupplier.SelectedIndices[0]; SupplierRepo.delete(Guid.Parse(lvSupplier.Items[index].SubItems[0].Text)); fillListView(); clearAll(); MessageBox.Show("Supplier has been deleted."); btnCategoryDelete.Enabled = false; btnCategoryUpdate.Enabled = false; btnCategoryAdd.Enabled = true; btnClear.Enabled = true; } catch (Exception) { MessageBox.Show("Please select a supplier to delete."); } } }