组合框数据源绑定会影响由相同数据设置的组合框的其他实例

时间:2016-02-29 10:17:35

标签: c# winforms

我有三个不同的组合框,我通过数据源分配相同的值,但每个选择更改都会影响其他实例。如何避免这种情况?

private void getVendorList()
{
  DataTable data = this.vendorService.GetAllVendors();
  this.LoadDataGridView(data);

  //set vendor combobox datasource
  comboAddProdVendorId.DataSource = data;
  comboAddProdVendorId.ValueMember = "Id";
  comboAddProdVendorId.DisplayMember = "Name";

  comboSearchProdVendorId.DataSource = data;
  comboSearchProdVendorId.ValueMember = "Id";
  comboSearchProdVendorId.DisplayMember = "Name";


  comboAddTransacVendorId.DataSource = data;
  comboAddTransacVendorId.ValueMember = "Id";
  comboAddTransacVendorId.DisplayMember = "Name";
}

1 个答案:

答案 0 :(得分:1)

在分配给数据源之前,您需要DIRECTORY DataTable 试试这个:

Copy