对不起,结束=接受用户编辑数据后,我在datagrid失去焦点时触发存盘事件,但正在编辑的
那个cell的数据有时不能自动保存到datatable里面,请问有什么方法或函数强迫datagrid接受录入的数据?

解决方案 »

  1.   

    只要调用update,更新到数据库就可以保存了,
      

  2.   

    private void EndEdit()
    {
        // Gets the CurrencyManager which is returned when the 
        // data source is a DataView.
        BindingManagerBase myMgr = 
            (CurrencyManager) BindingContext[myDataView];    // Gets the current row and changes a value. Then ends the 
        // edit and thereby keeps the changes.
        DataRowView tempRowView = (DataRowView) myMgr.Current;
        Console.WriteLine("Original: {0}", tempRowView["myCol"]);
        tempRowView["myCol"] = "These changes will be kept";
        Console.WriteLine("Edit: {0}", tempRowView["myCol"]);
        myMgr.EndCurrentEdit();
        Console.WriteLine("After EndCurrentEdit: {0}", 
            tempRowView["myCol"]);
    }这个 BindingManagerBase 是重点。每个绑定去会有一个的