I have two combobox in a form: Cb1 and Cb2
When I load the form, Cb1 and Cb2 are connected to a bindingsource.
When I change Cb1, the code (below) changes Cb2 to show only the items according to Cb1
This is working fine.
The problem is when I change Cb1 , change Cb2 and click the save button..... Cb2 seems to be 'lost'...

I'm using VS2008.

Thanks in advance!

Dim cnn As New OleDbConnection(stringConnect) 
        Dim ds As New DataSet()
        Try
            cnn.Open()
            Dim da As New OleDbDataAdapter("select * from TabSub where CodSup=" & CLng(Cb1.SelectedValue), cnn) 
            Me.Cb2.DisplayMember = "Descr"
            Me.Cb2.ValueMember = "CodeAcc"
            Me.Cb2.DataSource = ds.Tables(0)
            Me.Cb2.Refresh()
        Catch ex As Exception
            Throw New Exception(ex.Message)
        Finally
            cnn.Close()
        End Try

You'll need to provide the code that runs with the save button, as you are describing the problem to appear on save.
If Cb2 get's populated OK, then probably the code you are posting is irrelevant to your problem.

I'm using a binding navigator and the code when I save the register is :

Me.Validate()
 Me.BindingSource.EndEdit()
 Me.TableAdapter.Update(DataSet)

The second combobox (Cb2), after I save the register, seems to "loose" the binding source...
Any ideas?

Thanks!

Well, I think I found the answer myself....(some hours spent...)
After I save the record, I 'recover' cb2 databinding, and it's ok.

Thank you!

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.