问题
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