0

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

现在,我repositoryItemCheckEdit在属性部分创建了一个未绑定的布尔值,并添加了以truegridView1_CustomUnboundColumnData触发的事件,但当我单击复选框时,它永远不会为真。谁能解释这是为什么?谢谢e.IsGetDatae.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;
}
4

1 回答 1

0

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

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 值。

于 2011-04-06T06:59:23.543 回答