ComboBoxs, binds and sync

Hi!

I have two combos bind to a DataTable on this way:



cmb_ProvID.DataSource = BD.Tables["Provincias"];
cmb_ProvID.DisplayMember = "ID";
cmb_ProvID.ValueMember = "ID";

cmb_ProvName.DataSource = BD.Tables["Provincias"];
cmb_ProvName.DisplayMember = "NOMBRE";
cmb_ProvName.ValueMember = "ID";



When i change one, the other changes too.

But i have other two combos bind to a BindSource on this way:



BindingSource currentMunID = new BindingSource();
BindingSource currentMunName = new BindingSource();

currentMunID.DataSource=BD.Tables["Municipios"];
currentMunName.DataSource =BD.Tables["Municipios"];

cmb_MunID.DataSource = currentMunID;
cmb_MunID.DisplayMember = "ID";
cmb_MunID.ValueMember = "ID";

cmb_MunName.DataSource = currentMunName;
cmb_MunName.DisplayMember = "NOMBRE";
cmb_MunName.ValueMember = "ID";



And when i change one, the other not change, why I want that two combos change at same time, because one displays a ID and the other displays a name.

Thanks in advance.

Regards.



Answer this question

ComboBoxs, binds and sync

  • sandeep srivastava

    Hello All.

    Valeriano:

    Each BindingSource has its own CurrencyManager. Try this out:

    BindingSource currentMun = new BindingSource();

    currentMun.DataSource = BD.Tables["Municipios"];

    cmb_MunID.DataSource = currentMun;
    cmb_MunID.DisplayMember =
    "ID";
    cmb_MunID.ValueMember = "ID"
    ;

    cmb_MunName.DataSource = currentMun;
    cmb_MunName.DisplayMember = "NOMBRE"
    ;
    cmb_MunName.ValueMember = "ID";

    HTH.



  • David Ing

    Ah! ok.

    Thanks for your help ;D



  • ComboBoxs, binds and sync