zoukankan      html  css  js  c++  java
  • 关于Windows窗口保存前结束编辑的问题

    问题:
    窗口中控件绑定到dataSet1上,但调用this.BindingContext[this.dataSet1].EndCurrentEdit();
    程序并没有将当前的最新编辑存入dataSet1,

    解决方法:
    MSDN中说明了BindingContext的索引访问总是会返回一个BindingManagerBase,所以
    即使你传入了一个错误的参数,例如
    this.DataSet1也会有返回值,所以造成错误的认为调用是正确的。
    DataSet的绑定实际上内部是使用DataView实现的,所以有俩种解决方法:
    1、将控件绑定到DataView,而DataView关联DataSet,结束编辑时调用:
         BindingContext[this.dataview1].EndCurrentEdit();
         但这种方法如果有俩个表或更多调用就麻烦一些。
    2、直接寻找所有的绑定环境,并结束编辑。
                BindingManagerBase bm;
                foreach (System.Collections.DictionaryEntry item in
    this.BindingContext) {
                    bm = (item.Value as System.WeakReference).Target as
    BindingManagerBase;
                    if (bm != null) {
                        bm.EndCurrentEdit();
                    }
                }
  • 相关阅读:
    如何用vue实现树形菜单?
    spring+springMVC,声明式事务失效,原因以及解决办法
    java提高同步锁的几点建议
    java自定义before和after
    java线程池
    jdk并发工具包之锁
    ReentrentLock重入锁
    java守护线程
    ReentrantLock
    java多线程基础
  • 原文地址:https://www.cnblogs.com/tansm/p/180629.html
Copyright © 2011-2022 走看看