private void deleteRegistryValue_Click(object sender, EventArgs e) { //Prompt user to confirm delete string msg = "Deleting certain registry values could cause system instability. Are you sure you want to permanently delete " + (lstRegistryValues.SelectedItems.Count == 1 ? "this value?": "these values?"); string caption = "Confirm Value Delete"; var answer = MessageBox.Show(msg, caption, MessageBoxButtons.YesNo, MessageBoxIcon.Warning); if (answer == DialogResult.Yes) { foreach (var item in lstRegistryValues.SelectedItems) { if (item.GetType() == typeof(RegistryValueLstItem)) { RegistryValueLstItem registryValue = (RegistryValueLstItem)item; _registryHandler.DeleteRegistryValue(tvRegistryDirectory.SelectedNode.FullPath, registryValue.RegName); } } } }