private void deleteButton_Click(object sender, EventArgs e) { string key; key = Convert.ToString(artistList.SelectedItem); if (key != null && MessageBox.Show("Are you sure?", "Deleting artist", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes) { try { _artistList.Remove(key); artistList.ClearSelected(); UpdateDisplay(); } catch (Exception ex) { MessageBox.Show(ex.Message, "Error deleting artist"); } } }