diff --git a/src/UniversalValveToolbox/Model/ViewModel/FormProjectViewModel.cs b/src/UniversalValveToolbox/Model/ViewModel/FormProjectViewModel.cs index 8e01695..8e31c6c 100644 --- a/src/UniversalValveToolbox/Model/ViewModel/FormProjectViewModel.cs +++ b/src/UniversalValveToolbox/Model/ViewModel/FormProjectViewModel.cs @@ -34,7 +34,7 @@ namespace UniversalValveToolbox.Model.ViewModel { ForceUpdateField(value, ref selectProjectIndex); OnPropertyChanged(nameof(SelectProject)); - var index = Math.Max(engines.ToList().FindIndex(engine => engine.Appid == SelectProject.Engine), 0); + var index = Math.Max(engines.ToList().FindIndex(engine => engine.Appid == SelectProject?.Engine), -1); SelectEngineIndex = index; } diff --git a/src/UniversalValveToolbox/UI/FormProfiles.cs b/src/UniversalValveToolbox/UI/FormProfiles.cs index eadc5cb..b1deeae 100644 --- a/src/UniversalValveToolbox/UI/FormProfiles.cs +++ b/src/UniversalValveToolbox/UI/FormProfiles.cs @@ -85,7 +85,8 @@ namespace UniversalValveToolbox { } private void comboBoxEngine_SelectedIndexChanged(object sender, EventArgs e) { - model.SelectProject.Engine = ((EngineDtoModel)comboBoxEngine.SelectedItem).Appid; + if (model.SelectProject != null) + model.SelectProject.Engine = ((EngineDtoModel)comboBoxEngine.SelectedItem).Appid; } private void comboBox_Mod_SelectedIndexChanged(object sender, EventArgs e) {