更新:现在已解决,请参见下面的答案。 在我的一个窗体上(在Windows窗体应用程序中),我有3个组合框。这些组合框需要显示价格列表(在文本中,带有一个整数的后端值)。所有这些组合框都使用相同的数据源(TSPrice类型的List ,其中ValueMember设置为Price,DisplayMember设置为Description)。我的问题是...每当我从一个下拉列表中选择一个价格选项时,它们都将更改为相同的值...这是否与它们都绑定(bind)到同一数据源有关?这是我绑定(bind)它们的方式:var priceList = new List<TSPrice> { new TSPrice(0, ""), new TSPrice(0, "Half Day"), new TSPrice(0, "Full Day"), new TSPrice(0, "1 + Half"), new TSPrice(0, "2 Days"), new TSPrice(0, "Formal Quote Required") };objInsuredPrice.DataSource = priceList;objTPPrice.DataSource = priceList;objProvSum.DataSource = priceList;objInsuredPrice.ValueMember = "Price";objTPPrice.ValueMember = "Price";objProvSum.ValueMember = "Price";objInsuredPrice.DisplayMember = "Description";objTPPrice.DisplayMember = "Description";objProvSum.DisplayMember = "Description";objInsuredPrice.SelectedIndex = 0;objTPPrice.SelectedIndex = 0;objProvSum.SelectedIndex = 0;//objInsuredPrice.DataSource = objTPPrice.DataSource = objProvSum.DataSource = priceList;//objInsuredPrice.ValueMember = objTPPrice.ValueMember = objProvSum.ValueMember = "Price";//objInsuredPrice.DisplayMember = objTPPrice.DisplayMember = objProvSum.DisplayMember = "Description";//objInsuredPrice.SelectedIndex = objTPPrice.SelectedIndex = objProvSum.SelectedIndex = 0;编辑:问题在于,它们都被绑定(bind)到Saurabh确认的同一数据源。这就是我解决的方法。var priceList = new List<TSPrice> { new TSPrice(0, ""), new TSPrice(1, "Half Day"), new TSPrice(2, "Full Day"), new TSPrice(3, "1 + Half"), new TSPrice(4, "2 Days"), new TSPrice(5, "Formal Quote Required") };var insuredList = new TSPrice[5];var TPList = new TSPrice[5];var provList = new TSPrice[5];priceList.CopyTo(insuredList);priceList.CopyTo(TPList);priceList.CopyTo(provList);objInsuredPrice.DataSource = insuredList;objTPPrice.DataSource = TPList;objProvSum.DataSource = provList;objInsuredPrice.ValueMember = objTPPrice.ValueMember = objProvSum.ValueMember = "Price";objInsuredPrice.DisplayMember = objTPPrice.DisplayMember = objProvSum.DisplayMember = "Description";objInsuredPrice.SelectedIndex = objTPPrice.SelectedIndex = objProvSum.SelectedIndex = 0; (adsbygoogle = window.adsbygoogle || []).push({}); 最佳答案 我知道您并没有要求它,但我建议您稍微重构一下最终代码:-)private List<TSPrice> GetPriceList(){ return new List<TSPrice> { new TSPrice(0, ""), new TSPrice(0, "Half Day"), new TSPrice(0, "Full Day"), new TSPrice(0, "1 + Half"), new TSPrice(0, "2 Days"), new TSPrice(0, "Formal Quote Required") };}private void BindPriceList(ComboBox comboBox, List<TSPrice> priceList){ comboBox.DataSource = priceList(); comboBox.ValueMember = "Price"; comboBox.DisplayMember = "Description"; comboBox.SelectedIndex = 0;}BindPriceList(objInsuredPrice, GetPriceList());BindPriceList(objTPPrice, GetPriceList());BindPriceList(objProvSum, GetPriceList()); (adsbygoogle = window.adsbygoogle || []).push({});
10-04 11:38