Skip to main content

Enum To ListItem Collection

private System.ComponentModel.BindingList<ListItem> EnumToList(Type enumType)
{
System.ComponentModel.BindingList<ListItem> listItemBindingList = new System.ComponentModel.BindingList<ListItem>();
foreach (Enum item in Enum.GetValues(enumType))
{
ListItem lItem = new ListItem(item.ToString("D"), item.ToString("G"));
listItemBindingList.Add(lItem);
}
}



you can call the method
BindingList<ListItem> listItemBindingList = EnumToList(typeof(YourEnum));

Comments

Popular posts from this blog

Close Parent window from nested iframe child pages : javascript;

for : IE and FireFox 1: <script language="javascript" type="text/javascript"> 2: function CloseAll() { 3: if (top === self) { 4: alert('not iframed'); 5: if (navigator.appName == "Microsoft Internet Explorer") { 6: self.close(); 7: } 8: else { 9: var respnseVal = confirm("Do you wan't to close this window"); 10: if (respnseVal) { 11: netscape.security.PrivilegeManager.enablePrivilege("UniversalBrowserWrite"); 12: window.open('', '_self'); 13: window.close(); 14: } 15: } 16: } 17: else { 18: alert('iframed'); 19: if (navigator.appName == "Microsoft Internet Explorer") { 20: top.close(); 21: } 22: else { 23: var respnseVal = confirm("Do you w...

One of my old favorite Games - Z (Strategy)

Z - strategy game i used to love this game , it was quite fascinating strategy game around 1996 download : http://www.486games.net/game.php?id=173