private void SelectPort_SelectedIndexChanged(object sender, EventArgs e) { var prop = SerialPortHelper.GetComPortProperties(((COMPortItem)SelectPort.SelectedItem).Name); var result = (SerialPortHelper.Baud)prop.dwSettableBaud; var tmp = Enum.GetValues((typeof(SerialPortHelper.Baud))); var selectedItem = SelectBaudRate.SelectedItem; SelectBaudRate.Items.Clear(); var listBaud = new List <object>(); foreach (Enum br in tmp) { var item = GetEnumDescription(br); try { listBaud.Add(int.Parse(item)); } catch (FormatException) { continue; } } SelectBaudRate.Items.AddRange(listBaud.OrderBy(o => o).ToArray()); if (listBaud.Contains(selectedItem)) { SelectBaudRate.SelectedItem = selectedItem; } else { SelectBaudRate.SelectedItem = SelectBaudRate.Items[0]; } }