private void btnSaveSettings_Click(object sender, EventArgs e) { // Check if settings with the Name already exists NeedlemanWunschOptions optionsFound = this.lstOptions.FirstOrDefault(option => option.Name == this.txtName.Text); // If yes ask the user if he wants to replace them if (optionsFound != null) { if (MessageBox.Show(this.FindForm(), "Settings with this name already exist. Replace them?", "Question", MessageBoxButtons.YesNo, MessageBoxIcon.Question) != DialogResult.Yes) { return; } // We're still here, read the data from the gui into the object this.GetDataFromGui(optionsFound); } else { this.GetDataFromGui(this.options2Edit); // And append them to the list this.lstOptions.Add(this.options2Edit); } NeedlemanWunschOptions.SaveOptions(); MessageBox.Show(this.FindForm(), "Options saved!"); /* * // Refresh the ComboBox * this.cmbSettings.Items.Clear(); * this.cmbSettings.Items.AddRange(this.lstOptions.ToArray()); */ }