Is it possible to make a cell editable while in add new row mode and make readonly when its in Edit row cell
You don't need to allow cell editing for the add new row to work, so if the only row that will allow entry is the add new row, just don't turn on editing for the grid.
Otherwise you could simply put a check in the CellEnteringEditMode and check the e.Cell.Row.RowType to see if it's a RowType.DataRow and if it is set the e.Cancel event to true.
The user should be able to add and edit using the grid so I cannot turn off editing for grid
The CellEnteringEditMode looks like doption, but can I restrict it to only one cell that should not be editable in grid all others should be editable
If I give as below it disables editing for all columns in cell
private void Grid_CellEnteringEditMode(object sender, BeginEditingCellEventArgs e) { if (e.Cell.Row.RowType == RowType.DataRow) { e.Cancel = true; } }
If you want to do it for one column and it with the cell's column Key value
But it does not show intellisence for the .IsReadOnly?!
Perfect Thanks
IsReadOnly is off EditableColumn, the column object you get of e.Cell.Column would be an Column or ColumnBase object so you would need to cast it up to the correct level before setting that field.
EditableColumn ec = e.Cell.Column as EditableColumn;
if (ec!=null)
{
// do something
}
Now if the column is always read only, then you could set that flag either in the Xaml or one time in code, probably in the page loaded or grid loaded event.
If you can't set that flag and you wanted to not allow editing on a cell for a given column you would add
in the CellEnteringEditMode
if (e.Cell.Row.RowType == RowType.DataRow && e.Cell.Column.Key == "myKeyToNotAllowEditingOnThisColumn")
e.Cancel = true'