views:

96

answers:

2
+1  Q: 

WinForms binding

I have some controls bound to a BindingSource control.

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

Do i update the textbox the property is bound to or do i update the underlying entity which would update the control anyway(i hope)?

When i change comboboxA(onpropertychange)...textbox B is updated with the new calculated result..this works fine...but i have noticed that when i Leave combobox A..combobox A reverts back to its original value...what is 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
A: 

Tell more about your changing, how second text box is bound?
You have to change your initial data instead of changing textbox b value.
Also when textbox A loses it focus raises EndEdit event and I think binding mechanism refreshes value in textbox B.
You can control on which action editing is done when you setting your binding to textboxes.

mmcteam.com.ua
I have a an Entit(actually a llblgen entity) with many properties. Property A is bound to TextBoxA and property B is bound to TextBoxB. I have bound the controls using the property editor...how do i control the action editing... thanks in advance
Anthony
According to your previous answers you are setting value to textbox B on textboxA_OnChanged event, but you have to change propertyB and don't touch textboxB value. And changing that property you have by getting current item in your BindingSource and casting it to type of your datasource.
mmcteam.com.ua
Anthony
now you have to play with http://msdn.microsoft.com/en-us/library/system.windows.forms.bindingsource.suspendbinding.aspx and with RaiseListChangedEvents.Also you have to look how you added binding to textboxes, would be nice of you share that part of code.
mmcteam.com.ua
if you are using somthing like this textBox.DataBindings.Add("Text",bindingSounrce,"DataMember") there one more method .Add() where you can specify when binding is done(after your edit) and also you have to suspend binding until you change value in textBoxA and then on textBoxB
mmcteam.com.ua
+1  A: 

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

biluriuday