private void clearAllToolStripMenuItem_Click(object sender, EventArgs e) { DialogResult result = MessageBox.Show( "Do you want to clear (delete) these keys? This cannot be undone.", "Clear keys?", MessageBoxButtons.OKCancel, MessageBoxIcon.Exclamation); if (result != DialogResult.OK) { return; } KeyCollection.DeleteItemRange(new List <KeyCollectionItem>(KeyCollection.Items)); }