有没有办法让一个单元格可以在XtraGrid中只读取列?

时间:2013-06-21 21:22:39

标签: c# devexpress xtragrid

我的网格看起来像这样。

Key Value
1    A
2    B
3    C

我的网格中的值列只读。 "值" column的columnedit与memoexedit存储库相关联。现在我想做的是在某些情况下,比如当key = 2时, 我希望我的值单元格可以编辑。

我尝试将整列ReadOnly = false。

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

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

请帮忙!

1 个答案:

答案 0 :(得分:3)

尝试按照以下(半伪代码)处理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
}

通过这种方式,您可以根据需要优化已打开的编辑器。

相关问题