Is there a way to make a cell editable where column is readonly in XtraGrid?

那年仲夏 提交于 2019-12-14 02:04:39

问题


My grid looks like this.

Key Value
1    A
2    B
3    C

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.

I tried making the whole column ReadOnly = false.

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

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

Please help!


回答1:


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.



来源:https://stackoverflow.com/questions/17244501/is-there-a-way-to-make-a-cell-editable-where-column-is-readonly-in-xtragrid

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!