测试代码如下:
namespace cutpicturetest.comm { public class enumhelper { public static system.collections.arraylist getname(type enumtype) { system.collections.arraylist arr = new system.collections.arraylist(); string[] n = system.enum.getnames(enumtype); foreach (string item in n) arr.add(item); return arr; } public static t toenum<t>(string strenum) { t t = (t)enum.parse(typeof(t), strenum); return t; } public static system.collections.hashtable enumtohashtable(type enumtype) { system.collections.hashtable ht = new system.collections.hashtable(); array arr = system.enum.getvalues(enumtype); for (int i = 0; i < arr.length; i++) ht.add(convert.toint16(arr.getvalue(i)), arr.getvalue(i).tostring()); return ht; } } }
调用方式:
system.collections.hashtable arr = comm.enumhelper.enumtohashtable(typeof(timageformat)); foreach (string item in arr.values) cb.items.add(item);
其中的cb表示combobox对象,你可以替换成你的下拉框对象。
您可能感兴趣的文章:
如您对本文有疑问或者有任何想说的,请点击进行留言回复,万千网友为您解惑!
网友评论