c# - Enum to Drop Down Box to method -


basically, best way of doing this?

i have enum has possible resolutions , want them displayed on drop down combobox.

so far, found bind enum combobox like:

combobox2.datasource = enum.getnames(typeof(resolution)); 

however, in method, have:

public void testmethod(resolution res){} 

and can't think of way convert back. thinking of changing method use string, have case or ifs in method convert enum.

in addition, ideally want of names have spaces. have read [description("description spaces")] think gets applied on tostring.

even if sort of loop , add each item box via tostring, still return string.

i not sure how proceed other dump enum , go different approach.

i wondering in similar situation, do?

i use lookupedit instead, , tie enum value key , enum.getnames(typeof(resolutions)); displayed value on edit. when user selects item actual value instead of name.


Comments

Popular posts from this blog

c# - How to set Z index when using WPF DrawingContext? -

razor - Is this a bug in WebMatrix PageData? -

visual c++ - Using relative values in array sorting ( asm ) -