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
Post a Comment