zoukankan      html  css  js  c++  java
  • DevExpress 使用 GridControl 时,数据源无法立即更新的问题

    背景

    在使用 DevExpress 的 GridControl 为其实现 Checkbox 列,发现如果勾选了三行的数据,在遍历 GridControl 绑定的数据源时 Checkbox 列的数据仅有 2 行被更新。

    原因

    使用 Google 搜索了半天,在 DevExpress 的 Support 上找到了答案,似乎是需要手动调用 GridControl 关联 View 的 PostEditor() 方法。

    解决

    在这里我使用的是 GridControl 的 BandedGridView 视图,所以在获取数据源的时候,手动调用一下视图的 PostEditor() 即可。

    private void ButtonA_Click(object sender,EventArgs e)
    {
        bandedGridView1.PostEditor();
        
        if(gricControl1.DataSource is BindingList<ItemDto> items)
        {
            var checkedItems = item.Where(x=>x.IsUpdate);
        }
    }
    

    关于 PostEditor() 方法的解释:

    posts the value to the associated data source but doesn't close the active in-place editor.

  • 相关阅读:
    错因集锦
    组合数学12
    硬币购物
    考试套路整理
    考前模板整理
    我的友链
    P4127 [AHOI2009]同类分布
    P1836 数页码_NOI导刊2011提高(04)
    P4124 [CQOI2016]手机号码
    数位DP小结
  • 原文地址:https://www.cnblogs.com/myzony/p/10894658.html
Copyright © 2011-2022 走看看