/** * Selects a specific item in the combo box if exists according to its value. */ protected static void SelectItemByVal(ComboBox combo, int val) { MainFormHandler.SetIgnoreSourceMigrationChange(true); MainFormHandler.SetIgnoreTargetMigrationChange(true); int counter = 0; foreach (SimulatorOption simOption in combo.Items) { if (simOption.GetValue() == val) { combo.SelectedIndex = counter; break; } counter++; } MainFormHandler.SetIgnoreSourceMigrationChange(false); MainFormHandler.SetIgnoreTargetMigrationChange(false); }
/** * Fills a specific combo box with the migration options. */ protected static void FillMigrationComboOptions(ComboBox combo, int[] ignoreIDs, bool onlyInPC) { combo.Items.Clear(); for (int i = 0; i < allSimulatorOptions.Count; i++) { SimulatorOption optionObject = allSimulatorOptions[i]; if (optionObject == null) { continue; } if (ignoreIDs.Contains(optionObject.GetValue())) { continue; } if (onlyInPC && !simOptionsInPC.Contains(optionObject)) { continue; } combo.Items.Add(optionObject); } //Making sure the migration change event does not fire, or else an endless recursion will occur. MainFormHandler.SetIgnoreSourceMigrationChange(true); MainFormHandler.SetIgnoreTargetMigrationChange(true); if (combo.Items.Count > 0) { combo.SelectedIndex = 0; } MainFormHandler.SetIgnoreSourceMigrationChange(false); MainFormHandler.SetIgnoreTargetMigrationChange(false); }