博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
LookUpEdit - How update binding source immediately after selection?
阅读量:4980 次
发布时间:2019-06-12

本文共 4007 字,大约阅读时间需要 13 分钟。

解決辦法:

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?
Greetings
Marc
-----------------------------------------------
Ted (DevExpress Support) 2 years ago
Hi 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
        Michael
0
Svetlana (DevExpress Support) 3 years ago
Hi Michael,
Thank you for the message.
Please try to call the PropertyManager.EndCurrentEdit method in the TextEdit.EditValueChanged event handler:
    
[C#]Open in popup window
private 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,
Svetlana
0
3 years ago
Hi Svetlana,
generally your solution works, except the first time the value in the text box is changed, what could that be?
Thanks & best regards,
Michael
0
Svetlana (DevExpress Support) 3 years ago
Hi 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 window
private 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,
Svetlana
0
3 years ago
Hi Svetlana,
Thanks, this solution was the key to solve my problems.
Best regards,
Michael
0
Svetlana (DevExpress Support) 3 years ago
Hi 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

转载于:https://www.cnblogs.com/luoyaoquan/archive/2012/07/24/2606900.html

你可能感兴趣的文章
jQuery的选择器中的通配符[id^='code'] 【转】
查看>>
vmware osx10.12分辨率问题
查看>>
python 基础(十二) 图片简单处理
查看>>
Java知识总结-7
查看>>
Android Activity的创建、生命周期
查看>>
poj2676Sudoku
查看>>
TCSRM5961000
查看>>
《C++程序设计POJ》《WEEK4 运算符重载 》《第四周-编程填空》
查看>>
zookeeper集群管理配置优化总结
查看>>
如何配置openjdk的 java home
查看>>
JVM 内存分析
查看>>
(转)Spring中Singleton模式的线程安全
查看>>
实验报告 四
查看>>
Linux设备模型(6)_Bus
查看>>
NPM
查看>>
Laravel 快速开发标准文档
查看>>
Android——UI事件的处理机制(基于监听器)
查看>>
角谷猜想
查看>>
博客作业05-查找
查看>>
ubuntu16.04 删除内核
查看>>