private void DeleteButton_Click(object sender, EventArgs e) { var grid = VoicesDefaultsDataGridView; var selection = ControlsHelper.GetSelection <string>(grid, "name"); var itemsToDelete = SettingsFile.Current.Defaults.Where(x => selection.Contains(x.name)).ToArray(); MessageBoxForm form = new MessageBoxForm(); form.StartPosition = FormStartPosition.CenterParent; string message; if (itemsToDelete.Length == 1) { var item = itemsToDelete[0]; message = string.Format("Are you sure you want to delete settings for?\r\n\r\nName: {0}", item.name); } else { message = string.Format("Delete {0} setting(s)?", itemsToDelete.Length); } var result = form.ShowForm(message, "Delete", MessageBoxButtons.OKCancel, MessageBoxIcon.Exclamation); if (result == DialogResult.OK) { foreach (var item in itemsToDelete) { SettingsFile.Current.Defaults.Remove(item); } SettingsFile.Current.Save(); } }