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.

  • 相关阅读:
    poj2138 Travel Games
    [TJOI2013]松鼠聚会
    [HNOI2013]切糕
    CSS应用
    列表数据显示+分页
    SESSION的应用
    JS中正规表达式的用法以及常用的方法总结
    CSS 定位 (Positioning)
    CSS 边距
    选项卡应用
  • 原文地址:https://www.cnblogs.com/myzony/p/10894658.html
Copyright © 2011-2022 走看看