Live Chat Icon For mobile
Live Chat Icon

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

Platform: WinForms| Category: Data Binding

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';

Share with

Share on twitter
Share on facebook
Share on linkedin

Related FAQs

Couldn't find the FAQs you're looking for?

Please submit your question and answer.