WinForms binding

I have some controls associated with a BindingSource control.

I want to perform a calculation when a value changes in one control and sets the result on another control.

Am I updating the textbox that the property is bound to, or am I updating the underlying object that will update the control anyway (hopefully)?

When I change combobox A (OnPropertyChange), the new computed result is updated in textbox B. This works great, but I noticed that when I leave combobox A it reverts back to its original value. What's going on here!

Private Sub ComboBoxEditCostCode_EditValueChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ComboBoxEditCostCode.EditValueChanged
    Select Case ComboBoxEditCostCode.EditValue
        Case "7" 
            CType(TransactionEntityBindingSource.Current, TblTransactionsEntity).Qbdescription = "7-is here" 

        Case "2" 
            CType(TransactionEntityBindingSource.Current, TblTransactionsEntity).Qbdescription = "2-is here" 

        Case Else
            CType(TransactionEntityBindingSource.Current, TblTransactionsEntity).Qbdescription = "7-is here"
    End Select
End Sub

      

+2


a source to share


3 answers


if we bind the control to a source, then if the source changes, we can make its value automatically reflected in the control. About the problem you are facing, it would be better if you show the code snippet.



+1


a source


Tell us more about your change, how is the second textbox anchored?
You should change the original data instead of changing the value of the textbox b.
Also when textbox A loses it the focus raises the EndEdit event and I think the binding engine is updating the value in textbox B.
You can control what action is being edited when you bind the textboxes.



0


a source


generally, if you are using a binding source, you always CRUD data through it. Remember to call BindingSource.EndEdit when you are done, hope this helps

0


a source







All Articles