开发者

Last item in a bindingSource is not updating a combo box

I have a combo box bound to a Data Source (clientInfoBindingSource) for its selected item and text, I am using a auto generated Binding Navigator on a different Data Source (totalsBindingSource) and on

this.totalsBindingSource.CurrentChanged += new System.EventHandler(this.updateClientInfo);

it should update the current object for client info binding source.

private void updateClientInfo(object sender, EventArgs e)
{
    clientInfoBindingSource.Position = clientInfoBindingSource.Find("ClientID",ClientIDTextBox.Text);
}

On the last item in the list it is updating all of my text boxes correctly but the drop down software box will be blank.

Here is the autogenerated code for the combobox

// 
// 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.clientInfo开发者_Python百科BindingSource, "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;

Any pointers in the right direction. This datasource is bound to a Dataset which was auto-genrated from a SQL server.

To fill the drop down on load of the main form i do

this.clientSoftwareTableAdapter.Fill(this.clientsDataSet.ClientSoftware);
softwareComboBox.Items.AddRange(this.clientscDataSet.ClientSoftware.Select(a => a.Software).ToArray());

EDIT -- Changed the above code to use DataSourceUpdateMode.OnPropertyChanged but it did not affect the behavior.


At a glance: I would try setting the DataSourceUpdateMode to OnPropertyChanged


I have conceded defeat and will just change the combo box to a text box, making this answer to check it off.


I don't know if the question is still valid, but have you tried:

softwareComboBox.DataSource = this.clientsDataSet.
                                      ClientSoftware.
                                         Select(a => a.Software).ToArray();

instead of adding the items manually?

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜