I have a textbox that is bound (oneway) to a datatable that updates a couple of time a second. So the textbox value continually reflects changes in datatable. When I enter the textbox to manually set a value, the binding causes the value to continually be overwritten. How do I stop this? When I have entered a value (textbox lost focus) I want the textbox to return to display the bound value and not the value I have just entered manually.
I had the same problem and I solve it by
With the BindingNavigator, I set it to null
bdNavProduct.BindingSource =null;
With other textbox control, datagridview, I clear the DataBinding
txtProductID.DataBindings.Clear();
txtProductName.DataBindings.Clear();
txtQuantity.DataBindings.Clear();
txtUnitPrice.DataBindings.Clear();
dgvProduct.DataBindings.Clear();
Tony
You could attach to the text input event and cancel the binding and then reapply it on the lost focus event.
I think however you need to consider why you are displaying your bound value in a text box at all? Would it not be more appropriate to have an uneditable Textblock displaying your database information with the editable Textbox separate for the optional user input.
While what you are asking is doable using the Textbox event I mentioned, it seems like it would be confusing from a user perspective.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With