向ComboBox列表框中添加Enum的全部数据

相当于利用反射的 GetValues与GetNames

foreach (HETieXinType theType in Enum.GetValues(typeof(HETieXinType)))

foreach (string mode in Enum.GetNames(typeof(BooleanInteractionMode)))
{
ledResponseModesComboBox.Items.Add(mode);
switchResponseModesComboBox.Items.Add(mode);
}

从字符串变成枚举

(AITerminalConfiguration)Enum.Parse(typeof(AITerminalConfiguration), terminalConfigurationComboBox.SelectedItem.ToString())

原文地址:https://www.cnblogs.com/LongHuaiYu/p/4442421.html