【问题标题】:Is there a way to make a cell editable where column is readonly in XtraGrid?有没有办法使单元格可编辑,其中列在 XtraGrid 中为只读?
【发布时间】:2013-06-21 21:22:39
【问题描述】:

我的网格是这样的。

Key Value
1    A
2    B
3    C

我的网格中有只读值列。 “值”列的 columnedit 与 memoexedit 存储库相关联。现在我想做的是在某些条件下,例如当 key=2 时, 我希望我的值单元格是可编辑的。

我尝试将整个列设为 ReadOnly = false。

然后处理 ShowingEditor 以取消对除 Key=2 之外的所有内容的编辑,但这甚至会阻止打开编辑器以获取其他值。

我想要的是能够看到编辑器,但对于其他人应该是只读的 对于 Key=2,它应该是可编辑的。

请帮忙!

【问题讨论】:

    标签: c# devexpress xtragrid


    【解决方案1】:

    尝试如下处理 ShownEditor 事件(半伪代码):

    var grid = sender as GridView;
    if (grid.FocusedColumn.FieldName == "Value") {
        var row = grid.GetRow(grid.FocusedRowHandle) as // your model;
        // note that previous line should be different in case of for example a DataTable datasource
        grid.ActiveEditor.Properties.ReadOnly = // your condition based on the current row object
    }
    

    这样您就可以根据需要优化已经打开的编辑器。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2012-04-12
      • 2012-02-23
      • 1970-01-01
      • 2018-08-13
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多