.net - Combobox items from a list c# -


i'm new c# little please. i'm trying set items of combobox class's method.

public void province(string province) {      //naconst obj = new naconst();      province = uppercasefirst(province);      //string tempvar;      list<string> disttlistb = new list<string>();      disttlistb.add("quetta");      disttlistb.add("chaman");      disttlistb.add("gawadar");      disttlistb.add("kalat"); } 

this form takes province name textbox of form1 , should return list of district names accordingly.

you need change return type void list<string>

public list<string> province(string province) {      //naconst obj = new naconst();      province = uppercasefirst(province);      //string tempvar;      list<string> disttlistb = new list<string>();      disttlistb.add("quetta");      disttlistb.add("chaman");      disttlistb.add("gawadar");      disttlistb.add("kalat");       return disttlistb; } 

you can return list disttlistb.

you can invoke method follows , assign combobox datasource:

var districts = province("province"); combobox.datasource = districts; 

as additional note, you're not using province variable after have assigned not entirely sure wish there.


Comments

Popular posts from this blog

SPSS keyboard combination alters encoding -

Add new record to the table by click on the button in Microsoft Access -

CSS3 Transition to highlight new elements created in JQuery -