Question Can't bind selected value in combobox

imstac

New member
Joined
May 5, 2014
Messages
1
Programming Experience
1-3
I have two tables, Requests and Status. The Requests table has a field called status; which maps to the ID field in my Status lookup table. My status table has ID and Status fields.

I am trying to populate the options on my combobox with the records in my Status table and also assign the selectedvalue of a combobox to the status field in my Requests table.

Under combobox tasks, I have 'Use Databound Items' checked,

My datasource is my Status table, ID is the value and Status is the display
Under Seletedvalue, I have my status field selected from my RequestsBindingSource.

When I run the application the combbox shows all the records from the Status table but does not have the status field from the Requests table as the selectedvalue.

What am I doing wrong?

Here is my designer code:
VB.NET:
 Me.StatusComboBox.FormattingEnabled = True
        Me.StatusComboBox.Location = New System.Drawing.Point(628, 52)
        Me.StatusComboBox.Name = "StatusComboBox"
        Me.StatusComboBox.Size = New System.Drawing.Size(169, 21)
        Me.StatusComboBox.TabIndex = 42
        Me.StatusComboBox.DataSource = Me.ActiveStatusBindingSource
        Me.StatusComboBox.DisplayMember = "Status"
        Me.StatusComboBox.ValueMember = "ID"
        Me.StatusComboBox.DataBindings.Add(New System.Windows.Forms.Binding("SelectedValue", Me.RequestsBindingSource, "Status", True))
 
When I run the application the combbox shows all the records from the Status table but does not have the status field from the Requests table as the selectedvalue.

That code looks right. Are you saying that it's not automatically selecting the appropriate status for the current Request? I take it that that RequestsBindingSource is bound to some other controls? How are you selecting a Request?
 
Back
Top