Update unbound text box when bound text box is updated

dsk96m

Well-known member
Joined
Jan 11, 2013
Messages
173
Programming Experience
1-3
So i have a databound text box that changes value when value in a combobox changes. Next to the databound text box is an unbound text box that takes the value in the bound text box and divides it by 8. How do I make the unbound box change when the bound box changes. Right now it changes when the bound box changes, but it is showing the previous value divided by 8 instead of the current value.

If i try it in the combobox selectionchangecommitted event, it doesnt work, it just does what i mentioned above.

Any ideas?
 
What if you handle the TextChanged event on the bound textbox and set the text of the unbound TextBox when this event is triggered?

Another option that would probably work is to not use the data binding, but instead handle the SelectedIndexChanged event of the ComboBox to set the values of both TextBoxes.
 
i need it to work off the combobox selectionchangecommitted otherwise i get errors when loading crap, etc.
 
TextChanged event as mentioned can be used.
You could also add an expression column to your datatable that calculates the value, then bind this to the other textbox.
 
The column is added to your DataTable, either in dataset designer or in code, where you set its Expression property. It can also be a computed column in database, but don't need to be.
 
Back
Top