有没有办法使单元格可编辑,列在XtraGrid中是只读的? [英] Is there a way to make a cell editable where column is readonly in XtraGrid?

查看:289
本文介绍了有没有办法使单元格可编辑,列在XtraGrid中是只读的?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的网格看起来像这样。

My grid looks like this.

Key Value
1    A
2    B
3    C

我的网格中的值列是只读的。 Value列的columnedit与memoexedit存储库相关联。现在我想做的是在某些情况下,如key = 2,
我想要我的值单元格是可编辑的。

I have Value column read-only in my grid. "Value" column's columnedit is associated with memoexedit repository. Now what I want to do is on some condition like when key=2, I want my value cell to be editable.

我尝试制作整列ReadOnly = false。

I tried making the whole column ReadOnly = false.

,然后处理ShowsEditor以取消对Key = 2以外的其他任何编辑,但这阻止了打开其他值的编辑器。

and then handled ShowingEditor to cancel edit on everything else than Key=2, but that prevents even opening up the editor for other values.

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

What I want is able to see the editor but it should be readonly for Others and for Key=2, It should be editable.

请帮助!

推荐答案

尝试将ShownEditor事件处理为以下(半伪代码) :

Try to handle the ShownEditor event as the following (semi-pseudo code):

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
}

这样,您可以根据需要改进已打开的编辑器。

This way you could refine the already opened editor with your needs.

这篇关于有没有办法使单元格可编辑,列在XtraGrid中是只读的?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆