我有一個winform,其中包含一個bindingsource,其數據源是一個類型化的數據集。我在設計器中綁定了兩個文本框到同一列。當我更新任一文本框時,DatSet中的DataRow列將被正確更新,但表單上的其他文本框值不會更新。數據綁定用戶界面中的多個字段不更新
我缺少什麼?如何獲取數據綁定來更新第二個文本框?
注意:這是我需要這樣做的一個簡化示例,因爲在實際應用程序中,因爲一個控件是用戶可編輯的,另一個控件是用於計算的複合控件的輸入。
// Taken from InitializeComponent()
this.productsBindingSource.DataMember = "Products";
this.productsBindingSource.DataSource = this.dataSet1;
this.textBox1.DataBindings.Add(new Binding("Text", this.productsBindingSource, "UnitsInStock", true, DataSourceUpdateMode.OnPropertyChanged));
this.textBox2.DataBindings.Add(new Binding("Text", this.productsBindingSource, "UnitsInStock", true, DataSourceUpdateMode.OnPropertyChanged));
// Taken from Form Load Event
DataSet1TableAdapters.ProductsTableAdapter adapter = new DataSet1TableAdapters.ProductsTableAdapter();
adapter.Fill(dataSet1.Products);
代碼不幸的是,這並不適合我作爲寫入不同的現場發回導致循環中的數據源複合控件重新計算工作。此外,每次編輯單個屬性時,都會犯下一些錯誤。 –