Binding to ComboBox Issue

Posts   
 
    
Anthony
User
Posts: 155
Joined: 04-Oct-2006
# Posted on: 04-May-2010 08:48:10   

llblgen v2.6,adapter,vb.net,vs2008,winforms

I have a BindingSource(bound to a Entity).

The BindingSource is bound to a Combobox(CostCode) and a Text box(Field Qbdescription )

When someselects a value in the combobox..i populate the value iin the text box.

Public Class Form2
    Dim TransactionToSave = New TblTransactionsEntity
    Private Sub Form2_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load

        TblTransactionsEntityBindingSource.DataSource = TransactionToSave
    End Sub

    Private Sub CostCodeComboBoxEdit_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles CostCodeComboBoxEdit.SelectedIndexChanged
        Select Case CostCodeComboBoxEdit.EditValue
            Case "4"
                TransactionToSave.Qbdescription = "Here am i44444"  'A
            Case "5"
                TransactionToSave.Qbdescription = "Here am i555"      'B
            Case "6"
                TransactionToSave.Qbdescription = "Here am i666"      'C
        End Select
    End Sub
End Class

The above code works fine except the value selected in the combobox resets to nothing when is executes code at A, B or C

Weird..basicially when TransactionToSave.Qbdescription=<value> the event CostCodeComboBoxEdit.SelectedIndexChanged is triggered again!

Walaa avatar
Walaa
Support Team
Posts: 14950
Joined: 21-Aug-2005
# Posted on: 04-May-2010 10:18:34   

The BindingSource is bound to a Combobox(CostCode) and a Text box(Field Qbdescription )

Why do you bind the bindingSource to the TextBox?

Anthony
User
Posts: 155
Joined: 04-Oct-2006
# Posted on: 04-May-2010 12:24:05   

Entity TransactionToSave has many properties ..2 being QBDescription and CostCode.

When a user select a value from CostCode combobox..its populates QBDescription with text dependent on what cost code is selected.

I then save the cost code and QBDescription with SaveEntity()..

Walaa avatar
Walaa
Support Team
Posts: 14950
Joined: 21-Aug-2005
# Posted on: 04-May-2010 13:35:08   

Please try to call EndEdit() on the bindingSource before setting values from code.

Anthony
User
Posts: 155
Joined: 04-Oct-2006
# Posted on: 04-May-2010 15:39:09   

didn't help...

MTrinder
User
Posts: 1461
Joined: 08-Oct-2008
# Posted on: 04-May-2010 21:22:17   

Hmm, which properties of your entity are called when you change the value at A, B or C ?

Matt