TEL : +33 (0)9 72 13 15 17
Welcome
Services
Softwares
Competences
Contact
La boutique
Forums
Windows Forms FAQ resources
4. Windows Forms Data Binding
4.8 When I try to bind two comboboxes to the same datatable, both boxes show the same values, changing one changes the other. How do I make them have distinct values?
Make sure the two comboboxes use different BindngContext objects.
BindingContext bc = new BindingContext();
this.comboBox1.BindingContext = bc;
comboBox1.DataSource = _dataSet.Tables["orders"];
comboBox1.ValueMember = "CustomerID";
comboBox1.DisplayMember = "CustomerID";
bc = new BindingContext();
this.comboBox2.BindingContext = bc;
comboBox2.DataSource = _dataSet.Tables["orders"];
comboBox2.ValueMember = "CustomerID";
comboBox2.DisplayMember = "CustomerID";
online visitor count