AVaRICEDebugPackage.AVaRICEDebugSettingsControl.SetComboBoxValue C# (CSharp) Method

SetComboBoxValue() public static method

public static SetComboBoxValue ( ComboBox comboBox, string val ) : void
comboBox System.Windows.Forms.ComboBox
val string
return void
        public static void SetComboBoxValue(ComboBox comboBox, string val)
        {
            for (int i = 0; i < comboBox.Items.Count; i++)
            {
                if (comboBox.Items[i] is PropertyEntry.Enumerated.Suggestion && (comboBox.Items[i] as PropertyEntry.Enumerated.Suggestion).InternalValue == val)
                {
                    comboBox.SelectedIndex = i;
                    return;
                }
            }

            var item = new PropertyEntry.Enumerated.Suggestion { InternalValue = val };
            comboBox.Items.Add(item);
            comboBox.SelectedItem = item;
        }