c# - enum to comboBox except some of enum elements -


for example have enum:

private enum categories { foo, foobar, bar } 

at way fill combobox elements of enum:

mycombobox.itemssource = enum.getvalues(typeof(categories)).cast<categories>(); 

but how bind enum elements except categories.foobar example?

you can use where:

enum.getvalues(typeof(categories))       .cast<categories>()       .where(x => x != categories.foobar).tolist(); 

Comments

Popular posts from this blog

php - Extract Text from HTTP referer -

Receive udp packets in android gstreamer -

authentication - ASP.NET Core 1.0. Bearer Token, cannot access custom claims -