c# - Why i can't return my method? -


i have enum contains languages english, french, spanish, german ...

i have below method return combobox instance has enum datasource:

  public combobox updatecomboboxidioma()         {             comboidioma.datasource = enum.getvalues(typeof(idioms));              return comboidioma;//it return 6 languages         } 

i assigning resulted combobox of method combobox in form, show languages this:

combobox2 = classedefinicoes.updatecomboboxidioma(); 

but not show languages on form.

what problem?

in opinion not idea return combo control method. instead should values idioms enum , set datasource of combo -

var combosource = enum.getvalues(typeof(idioms)); this.combobox2.datasource = combosource; 

or if prefer 1 liners :)

this.combobox2.datasource = enum.getvalues(typeof(idioms)); 

Comments

Popular posts from this blog

java - Date formats difference between yyyy-MM-dd'T'HH:mm:ss and yyyy-MM-dd'T'HH:mm:ssXXX -

c# - Get rid of xmlns attribute when adding node to existing xml -