c# - Update a combobox from a presenter (MVP) -


i using mvp in project, new in mvp. have 2 comboboxes. when select option in combobox, combobox should filled new data.

this action in presenter. view 'view1' in presenter, , introduced combobox1 , combobox2 properties in 'view1', because need 'datasource', 'displaymember', 'valuemember' , 'refresh()' in method below.

but, when using pattern, enough send property like

public string combobox2 {     { return combobox1.selectedvalue.tosstring(); } } 

into presenter not whole combobox. how can solve problem?

public void onselectedindexchangedcombobox1() {     if (view1.combobox1.selectedindex == -1)     {         return;     }      datatable dt = tools.getdatatable("a path");      var query =         (from o in dt.asenumerable()          o.field<string>("afield") ==               farmerview.combobox1.selectedvalue.tostring()          orderby o.field<string>("anotherfield")          select new keyvaluepair<string, string>(o.field<string>("field1"),               o.field<string>("field2"))).tolist();      farmerview.combobox2selectedindexchanged -= onselectedindexchangedcombobox2;      farmerview.combobox2.datasource = new bindingsource(query, null);     farmerview.combobox2.displaymember = "value";       farmerview.combobox2.valuemember = "key";        farmerview.combobox2.refresh();     farmerview.combobox2selectedindexchanged +=         onselectedindexchangedcombobox2;      farmerview.combobox2.selectedindex = -1; } 

thank you

you should not pass android objects presenter, event in view (for instance activity) call method presenter provides data second combobox (we call spinner in android!) passing selected item first one, , presenter call method of view fill second 1 , view knows how it.

you can take @ sample project http://github.com/mmirhoseini/marvel , article https://hackernoon.com/yet-another-mvp-article-part-1-lets-get-to-know-the-project-d3fd553b3e21 more familiar mvp.


Comments

Popular posts from this blog

Command prompt result in label. Python 2.7 -

javascript - How do I use URL parameters to change link href on page? -

'hasOwnProperty' in javascript -