vb.netgridviewdevexpressbasicdevexpress-gridcontrol

First column of GridView readonly unless new row


I have a GridView with various columns and rows pulled from a database.

In the first column I have a dateEdit repository item.

What I would like to do is have this first column readonly for all rows except when the user clicks "Add new row" as the user will need to edit the date on new rows.

I have been trying using the ShowingEditor() event and e.Cancel however this makes the whole row readonly and not just the first column (the rows have other repository items like TextEdits).

I am using DevExpress with Visual Basic and Visual Studio 2019.


Solution

  • In ShowingEditor event you can use FocusedColumn property to set e.Cancel = True only for particular columns.

    If YourGridView.FocusedColumn.FieldName = "YourDateEditColumn" Then
        e.Cancel = True
        Exit Sub
    End If