C# 枚举绑定到ComboBox
enum TestEnum {zero=0,one=1,two=2} ComboBox cbo = new ComboBox(); cbo.DataSource = System.Enum.GetNames(typeof(TestEnum)); enum test=enum.one; cbo.SelectedIndex = this.cbo.FindString(test.ToString()); 取值 TestEnum testenum = (TestEnum)Enum.Parse(typeof(TestEnum) ,cbo.SelectedItem.ToString() ,false) 方法二: foreach (var v in typeof(AA).GetFields()) { if (v.FieldType.IsEnum == true) { this.comboBox1.Items.Add(v.Name); } } this.comboBox1.SelectedIndex = 1; 方法三: 反射,枚举,绑定下拉框 public static class EnumManager<TEnum> { private static DataTable GetDataTable() { Type enumType = typeof(TEnum); // 获取类型对象 游天居士到此一游 FieldInfo[] enumFields = enumType.GetFields(); //获取字段信息对象集合 DataTable table = new DataTable(); table.Columns.Add("Name", Type.GetType("System.String")); table.Columns.Add("Value", Type.GetType("System.Int32")); //遍历集合 foreach (FieldInfo field in enumFields) { if (!field.IsSpecialName) { DataRow row = table.NewRow(); row[0] = field.Name; // 获取字段文本值 row[1] = Convert.ToInt32(field.GetRawConstantValue()); // 获取int数值 //row[1] = (int)Enum.Parse(enumType, field.Name); 也可以这样 table.Rows.Add(row); } } return table; }