I need to bind to Combobox
to automatically save the data in the database.
* I fill Combobox
when starting Form
:
lPropositosInmueble = BOPropositoInmueble.PropositoInmuebleCollection
With Me.cboProposito
.DisplayMember = "Nombre"
.ValueMember = "PropositoID"
.DataSource = lPropositosInmueble
.SelectedIndex = -1
End With
When I search for the data in the table, I match the Combobox
and apply the binding:
bindingPropositoiImueble = New Binding("SelectedValue", lPropositosInmueble, "Nombre", True, DataSourceUpdateMode.OnPropertyChanged, Nothing)
Me.cboProposito.DataBindings.Add(bindingPropositoiImueble)
Me.cboProposito.SelectedValue = captacion.PropositoInmuebleID
To save:
If captacion.IsDirty = False Then
captacion.Update()
End If
captacion
is an object (table) already instantiated and that is saving the other data of Textbox
in this way:
Me.txtPrecioCLP.DataBindings.Add(New Binding("Text", captacion, "Precio", True, DataSourceUpdateMode.OnValidation, Nothing, "C0"))
The problem is that it does not save what I selected in Combobox
when I want to make a change, for the Textbox
I do the same and it works perfectly for me.