Winforms Windows窗体组合框自动同步;为什么?

Winforms Windows窗体组合框自动同步;为什么?,winforms,combobox,dataset,Winforms,Combobox,Dataset,在VS2010中,我创建了一个数据绑定表单,从数据源窗口拖动到一个空表单。数据源(类型化数据集)有两列:CustomerCode和CustomerName。在表单的加载事件中,我写道: private void SalesInvoiceForm_Load(object sender, EventArgs e) { //Populate customer code combobox var customerTableAdapter = new companyDataSetTableAdap

在VS2010中,我创建了一个数据绑定表单,从数据源窗口拖动到一个空表单。数据源(类型化数据集)有两列:CustomerCode和CustomerName。在表单的加载事件中,我写道:

private void SalesInvoiceForm_Load(object sender, EventArgs e)
{
  //Populate customer code combobox
  var customerTableAdapter = new companyDataSetTableAdapters.CustomerTableAdapter();
  customerTableAdapter.Fill(this.companyDataSet.Customer);
  customerCodeComboBox.DataSource = this.companyDataSet.Customer;
  customerCodeComboBox.ValueMember = "Code";
  customerCodeComboBox.DisplayMember = "Code";

  //Populate customer name combobox
  //customerNameComboBox.DataSource = this.companyDataSet.Customer;
  customerNameComboBox.ValueMember = "Name";
  customerNameComboBox.DisplayMember = "Name";


  this.salesInvoiceTableAdapter.Fill(this.companyDataSet.SalesInvoice);
}
不知何故,当我从customerCodeComboBox中选择客户代码时,customerNameComboBox会自动同步,即显示所选客户的名称。customerNameComboBox也是如此。最初我认为每个组合框的SelectedIndexChanged事件handler都需要一个代码,两个都需要同步。为什么会自动发生这种情况?因为它们的DataSource属性设置为相同的datatable?我认为datatable没有任何与位置相关的功能

为什么会自动发生这种情况?因为它们的DataSource属性设置为相同的datatable

我认为datatable没有任何与位置相关的功能


事实并非如此;但是绑定系统使用了一个幕后操作系统,它处理当前项的概念。

但是表单没有customerBindingSource。不过它有一个绑定源。另外,我注意到DataGridView中的ComboxBox也不适用于此。你能解释一下吗?