0

Now when i select item in first combo box the second mimic the selection. I want to be able to select in each of the combo boxes individually. Thanks.

 List<W6AdminUIs2.DictionaryObject> taskStatuses = W6AdminUIs2.GlobalFunctions.GetDictionaryItems("TaskStatus");

    // Init the binding source of the statuses.
    BindingSource bsFromStatuses = new BindingSource();
    bsFromStatuses.DataSource = taskStatuses;

    //Bind the "From" combo box to binding source.
    cBoxFrom.DataSource = bsFromStatuses.DataSource;
    cBoxFrom.DisplayMember = "Name";
    cBoxFrom.ValueMember = "Key";

    // Init the binding source of the statuses.
    BindingSource bsToStatuses = new BindingSource();
    bsToStatuses.DataSource = taskStatuses;

    //Bind the "From" combo box to binding source.
    cBoxTo.DataSource = bsToStatuses.DataSource;
    cBoxTo.DisplayMember = "Name";
    cBoxTo.ValueMember = "Key";
Alexander Gorelik
  • 3,985
  • 6
  • 37
  • 53

1 Answers1

5

I don't know what kind of dictionary you are using but i use normal dictionary and this code dont behave like that :

Dictionary<string,string> dict = new Dictionary<string, string>();
dict.Add("S1", "Sample1");
dict.Add("S2", "Sample2");
dict.Add("S3", "Sample3");
dict.Add("S4", "Sample4");

comboBox1.DataSource = new BindingSource(dict, null);
comboBox1.DisplayMember = "value";
comboBox1.ValueMember = "key";

comboBox2.DataSource = new BindingSource(dict, null);
comboBox2.DisplayMember = "value";
comboBox2.ValueMember = "key";
SerkanOzvatan
  • 231
  • 1
  • 5