1

I am looking to be able to set a cell editability so that it is possible to select the inner text of a cell in a GridControl without being able to modify it.

Note: this behavior can be achieved at a column level by setting the ReadOnly to true, however want it at cell level

Thank you!

goul
  • 813
  • 1
  • 13
  • 32
  • possible duplicate of [DevExpress GridControl cells' inner text selectable but not editable](http://stackoverflow.com/questions/26172343/devexpress-gridcontrol-cells-inner-text-selectable-but-not-editable) – DmitryG Oct 06 '14 at 05:50
  • @DmitryG - It's not a duplication. for this situation, the solution would be to create a named style with a targettype of the cell editor type, include a setter for property "IsEnabled" and bind that to a view model or back end property returning a boolean value. – stephenbayer Sep 22 '15 at 22:38

1 Answers1

2

Try assigning a RespositoryItemTextEdit control that cell within the GridView's CustomRowCellEdit event. Set the ReadOnly property of this RepositoryItemTextEdit to True and assign it to the cell based on your conditions.

private void gridView1_CustomRowCellEdit(object sender, DevExpress.XtraGrid.Views.Grid.CustomRowCellEditEventArgs e)
{
    if (e.Column == gridView1.Columns["EmployeeName"] && e.RowHandle == 2)
    {
        //Don't allow users to edit Employee Name in the third row cell
        RepositoryItemTextEdit readOnlyTextEdit = new RepositoryItemTextEdit();
        readOnlyTextEdit.ReadOnly = true;

        e.RepositoryItem = readOnlyTextEdit;
    }
}
Brendon
  • 1,238
  • 1
  • 7
  • 8
  • Thank you. But are you talking about WinForm or WPF? I'm using a GridControl > TableView and can't find where to hook that event – goul Oct 10 '14 at 10:32