解決辦法:
ctDropInput1.AaaLookUpEdit1.DataBindings[0].WriteValue();
ctTxtHid1.CtTxtCommon1.TextEdit1.DataBindings[0].WriteValue();ctTxtHidOperator1.CtTxtCommon1.TextEdit1.DataBindings[0].WriteValue();--------------------------------------------------
from:http://www.devexpress.com/Support/Center/p/Q319769.aspx
Dear support team!I feel very stupid to bother you with this. I have read other threads, but I am not sure how they solve my problem:I have on LookUpEdit control on a Winforms form. It is bound to one field of a datasource.Desired behavior: When the user selects an item, I want the LookUpEdit to close and update the bindingsource. But I just don't get it.I have tried to handle the EditValue_Changing event, but I do not know how to force the Update.This should not be too hard. What do I overlook?GreetingsMarc-----------------------------------------------Ted (DevExpress Support) 2 years agoHi Marc,Yes, when the EditValueChanged is raised the binding engine usually doesn't have enough time to update a bound data source. So, you can simply wrap code in the EditValueChanged in the BeginInvoke method. This will postpone the code execution after the binding engine does its job. Another way it to set the DataSourceUpdateMode to "Never" and manually update the value using the Binding's WriteValue method in the EditValueChanged event handler.Thanks,Ted-----------------------------------------------Thanks Ted. This should help me. Thanks a lot.-----------------------------------------------from:http://www.devexpress.com/Support/Center/p/Q251024.aspx Hello, I have a simple data binding: [C#]Open in popup window this.textEdit.DataBindings.Add( new Binding( "EditValue", anyBusinessObject, "PropertyName", true, DataSourceUpdateMode.OnPropertyChanged)); I also attach an event hanlder to the EditValueChanged event: [C#]Open in popup window this.textEdit.EditValueChanged += this.TextEdit_EditValueChanged; At the time when the event handler gets called, the value of the bound business object property still has the old value. [C#]Open in popup window private void TextEdit_EditValueChanged(object sender, EventArgs e) { // here the value is not updated yet: // businessObject.AnyProperty != textEdit.EditValue } How can I force the data binding, that the business object property is already updated at this time? To use directly textEdit.EditValue is not an option in this case. Thanks for help, best regards Michael0Svetlana (DevExpress Support) 3 years agoHi Michael,Thank you for the message.Please try to call the PropertyManager.EndCurrentEdit method in the TextEdit.EditValueChanged event handler: [C#]Open in popup windowprivate void TextEdit_EditValueChanged(object sender, EventArgs e) { PropertyManager manager = BindingContext[businessObject] as PropertyManager; manager.EndCurrentEdit(); Text = businessObject.AnyProperty.ToString(); }Please try this approach, and let me know your results.Thanks,Svetlana03 years agoHi Svetlana,generally your solution works, except the first time the value in the text box is changed, what could that be?Thanks & best regards,Michael0Svetlana (DevExpress Support) 3 years agoHi Michael,Thank you for the feedback.Please try to use the Binding.WriteValue method to immediately refresh the property's value: [C#]Open in popup windowprivate void TextEdit_EditValueChanged(object sender, EventArgs e) { PropertyManager manager = BindingContext[businessObject] as PropertyManager; if(manager.Bindings.Count != 0) manager.Bindings[0].WriteValue(); Text = businessObject.AnyProperty.ToString(); }Does this solution work for you?Thanks,Svetlana03 years agoHi Svetlana,Thanks, this solution was the key to solve my problems.Best regards,Michael0Svetlana (DevExpress Support) 3 years agoHi Michael,Please don't hesitate to contact us in case of any difficulty. We will be happy to help you resolve any problem!Thanks,Svetlana