我有一個組合框綁定到數據源(clientInfoBindingSource)爲其選定的項目和文本,我使用自動生成的綁定導航器上不同的數據源(totalsBindingSource)並在bindingSource中的最後一項是不更新組合框
this.totalsBindingSource.CurrentChanged += new System.EventHandler(this.updateClientInfo);
它應該更新客戶端信息綁定源的當前對象。
private void updateClientInfo(object sender, EventArgs e)
{
clientInfoBindingSource.Position = clientInfoBindingSource.Find("ClientID",ClientIDTextBox.Text);
}
對於列表中的最後一項,它正在更新我所有的文本框,但下拉軟件框將爲空白。
下面是該組合框
//
// softwareComboBox
//
this.softwareComboBox.DataBindings.Add(new System.Windows.Forms.Binding("SelectedItem", this.clientInfoBindingSource, "Software", true, System.Windows.Forms.DataSourceUpdateMode.OnPropertyChanged));
this.softwareComboBox.DataBindings.Add(new System.Windows.Forms.Binding("Text", this.clientInfoBindingSource, "Software", true, System.Windows.Forms.DataSourceUpdateMode.OnPropertyChanged));
this.softwareComboBox.FormattingEnabled = true;
this.softwareComboBox.Location = new System.Drawing.Point(106, 234);
this.softwareComboBox.Name = "softwareComboBox";
this.softwareComboBox.Size = new System.Drawing.Size(220, 21);
this.softwareComboBox.TabIndex = 23;
在正確的方向的任何指針自動生成的代碼。 此數據源綁定到從SQL服務器自動生成的數據集。
填補了下拉的主要形式的負載我做
this.clientSoftwareTableAdapter.Fill(this.clientsDataSet.ClientSoftware);
softwareComboBox.Items.AddRange(this.clientscDataSet.ClientSoftware.Select(a => a.Software).ToArray());
編輯 - 改變了上面的代碼使用DataSourceUpdateMode.OnPropertyChanged但它並沒有影響行爲。
更改它不起作用。任何其他想法? – 2010-01-15 21:35:01
我將不得不重玩這個問題。偶然,你不會有一個可運行的例子來顯示這個問題嗎? – STW 2010-01-15 21:39:51
你有一個電子郵件地址給你一些源代碼塊嗎?我不想公開發布它。 – 2010-01-15 22:12:10