void cboConfigFile_SelectionChangeCommitted(object sender, EventArgs e) { // Check if there is a difference compared to the configuration we are switching to var defaultProperties = new MainSettings(); defaultProperties.SetDefault(); var resultingProperties = ConfigurationHelper.GetMainProperties( GetConfigFileUseFromUIIndex(cboConfigFile.SelectedIndex), defaultProperties, null); if (MainSettings.Equals(resultingProperties)) { lastConfigFileIndex = cboConfigFile.SelectedIndex; ConfigFileUse = GetConfigFileUseFromUIIndex(lastConfigFileIndex); return; } var answer = MessageBox.Show("One or more settings are different in the configuration file selected. " + "Do you want to use the settings from " + $"{ConfigUseForUI[cboConfigFile.SelectedIndex]}?", "Use new config file settings", MessageBoxButtons.YesNoCancel, MessageBoxIcon.Question); switch (answer) { case DialogResult.Yes: GetAndShowProperties(cboConfigFile.SelectedIndex); break; case DialogResult.No: break; case DialogResult.Cancel: cboConfigFile.SelectedIndex = lastConfigFileIndex; return; // Don't do anything else default: throw new InvalidDataException("Unexpected value returned from MessageBox."); } // We get if either Yes or No was selected lastConfigFileIndex = cboConfigFile.SelectedIndex; ConfigFileUse = GetConfigFileUseFromUIIndex(lastConfigFileIndex); }