单击 checkEdit 项目时,网格控件中的 IsSetData 永远不会为 true

发布于 2024-10-31 04:26:48 字数 789 浏览 6 评论 0原文

我有这个 DevExpress GridControl,我添加了两个列,一个包含 repositoryItemCheckEdit ,另一个包含正常的 string 类别描述。

现在,我已将 repositoryItemCheckEdit 设为属性部分中的未绑定布尔值,并添加了 gridView1_CustomUnboundColumnData 事件,该事件以 e.IsGetData true 触发,但当我单击复选框时,e.IsSetData 永远不会为真。谁能解释这是为什么吗? 谢谢

private void gridView1_CustomUnboundColumnData(object sender, CustomColumnDataEventArgs e)
{
  if (e.IsGetData)
  {
    string itemKey = ((CategoryTable)(gridControl1.ViewCollection[0]).GetRow(e.RowHandle)).Category;
    if (AddressDoc == itemKey) e.Value = true
    else e.Value = false;
  }

  if (e.IsSetData)
    AddressDoc = ((CategoryTable)(gridControl1.ViewCollection[0]).GetRow(e.RowHandle)).Category;
}

I have this DevExpress GridControl which I've added with two coloums the one containing a repositoryItemCheckEdit and the other normal string Category description.

Now I've made the repositoryItemCheckEdit a unbound bool in the property section and added the gridView1_CustomUnboundColumnData event which fires with e.IsGetData true but the the e.IsSetData is never true when I click on the check box. Can anyone explain why this is?
Thanks

private void gridView1_CustomUnboundColumnData(object sender, CustomColumnDataEventArgs e)
{
  if (e.IsGetData)
  {
    string itemKey = ((CategoryTable)(gridControl1.ViewCollection[0]).GetRow(e.RowHandle)).Category;
    if (AddressDoc == itemKey) e.Value = true
    else e.Value = false;
  }

  if (e.IsSetData)
    AddressDoc = ((CategoryTable)(gridControl1.ViewCollection[0]).GetRow(e.RowHandle)).Category;
}

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

蔚蓝源自深海 2024-11-07 04:26:48

请尝试如何保存 in- 的值中的解决方案一旦更改,请立即放置复选框我们网站上发布的知识库文章。它应该可以帮助您解决这个问题。另外,我已经检查了您的代码,它看起来并不安全。我将其更改如下:

private void gridView1_CustomUnboundColumnData(object sender, CustomColumnDataEventArgs e) {
            GridView gridView = sender as GridView;
            DataView dv = gridView.DataSource;
            object c = DataView[e.ListSourceRowIndex]["Category"];
            string itemKey = c == null ? "" : c.ToString();
            if (e.IsGetData) {
                if(AddressDoc == itemKey)
                    e.Value = true;
                else 
                    e.Value = false;
            }
            if(e.IsSetData)
                AddressDoc = itemKey;
        }

我只能认为您没有正确调整未绑定的列。注意:列应满足两个强制条件才能解除绑定:
1)它的FieldName应该设置为其他GridView列的fieldName属性中的唯一值;
2) 列的UnboundType 应设置为非Bound 值。

Please try the solution from the How to save the value of an in-place check box as soon as it is changed knowledge base article published on our web site. It should help you resolve this problem. Also, I have reviewed your code and it does not look to be safe. I would change it as follows:

private void gridView1_CustomUnboundColumnData(object sender, CustomColumnDataEventArgs e) {
            GridView gridView = sender as GridView;
            DataView dv = gridView.DataSource;
            object c = DataView[e.ListSourceRowIndex]["Category"];
            string itemKey = c == null ? "" : c.ToString();
            if (e.IsGetData) {
                if(AddressDoc == itemKey)
                    e.Value = true;
                else 
                    e.Value = false;
            }
            if(e.IsSetData)
                AddressDoc = itemKey;
        }

I can only think that you did not properly adjusted the unbound column. NOTE: a column should meet two mandatory conditions to be unbound:
1) it's FieldName should be set to a unique value among fieldName properties of other GridView columns;
2) the column's UnboundType should be set to the non Bound value.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文